Issue634292

classification
Title: read and readline don't mix
Type: Severity: normal
Components: None Versions:
Milestone:
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: dalke, kzuberi
Priority: low Keywords:

Created on 2002-11-06.07:59:48 by dalke, last changed 2006-09-12.18:28:46 by kzuberi.

Messages
msg787 (view) Author: Andrew Dalke (dalke) Date: 2002-11-06.07:59:48
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)
>

msg788 (view) Author: Khalid Zuberi (kzuberi) Date: 2006-09-12.18:28:46
Logged In: YES 
user_id=18288

Can reproduce in 2.1, already fixed in 2.2. Closing.

- kz
History
Date User Action Args
2002-11-06 07:59:48dalkecreate