Message787

Author dalke
Recipients
Date 2002-11-06.07:59:48
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Unlike CPython, Jython 2.1 cannot support both 'read' and
'readline' from the same file.  Do a 'file.readline()'
and a
subsequent 'file.read()' will return the empty string.

I cannot find mention of this difference in the Jython docs
nor in the bug pages nor have I seen it mentioned
on c.l.py nor in Google.  Here's a reproducible

[dalke@zebulon ~/tmp]$ cat > input.txt
This is line 1
This is line 2
This is line 3
[dalke@zebulon ~/tmp]$ python
Python 2.2.1 (#1, Apr 15 2002, 14:36:39)
[GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-98)] on linux2
Type "help", "copyright", "credits" or "license" for
more information.
>>> f = open("input.txt")
>>> f.readline()
'This is line 1\n'
>>> f.read()
'This is line 2\nThis is line 3\n'
>>>
[dalke@zebulon ~/tmp]$ jython
Jython 2.1 on java1.4.0_01 (JIT: null)
Type "copyright", "credits" or "license" for more
information.
>>> f = open("input.txt")
>>> f.readline()
'This is line 1\n'
>>> f.read()
''
>>>
[dalke@zebulon ~/tmp]$

If it makes a difference, I'm using Jython on a Linux
box (RedHat 7.3) on top of

                              Blackdown Java-Linux

                      Java(TM) 2 SDK, Standard Edition
                             Version 1.4.1-beta
                  (Based on Sun's Version 1.4.1-pre-rc-b17)

But I don't think it makes a difference since I just
reran the test (with the same problem) under a Solaris
box with 

> java -version
java version "1.2.2"
Solaris VM (build Solaris_JDK_1.2.2_05a, native
threads, sunwjit)
>

History
Date User Action Args
2008-02-20 17:17:11adminlinkissue634292 messages
2008-02-20 17:17:11admincreate