[Python-bugs-list] [ python-Bugs-487277 ] Different behavior of readline()

noreply@sourceforge.net noreply@sourceforge.net
Fri, 30 Nov 2001 04:21:06 -0800


Bugs item #487277, was opened at 2001-11-29 14:43
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=487277&group_id=5470

Category: Python Interpreter Core
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Gustavo Niemeyer (niemeyer)
Assigned to: Nobody/Anonymous (nobody)
Summary: Different behavior of readline()

Initial Comment:
The behavior of readline() has changed on 2.2. This 
should be documented.

Example:

Python 2.1 (#1, Jun 22 2001, 17:13:13)
[GCC 2.95.3 20010315 (release) (conectiva)] on 
linux-i386
Type "copyright", "credits" or "license" for more 
information.
>>> open("/etc").readline()
''

Python 2.2b2+ (#1, Nov 27 2001, 21:39:35)
[GCC 2.95.3 20010315 (release) (conectiva)] on 
linux-ppc
Type "help", "copyright", "credits" or "license" for 
more information.
>>> open("/etc").readline()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
IOError: [Errno 21] Is a directory



----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2001-11-30 04:21

Message:
Logged In: YES 
user_id=21627

Well, I wouldn't object to anybody documenting this
particular change (even though I won't do that myself, either).

I'm just pointing out that there are many more changes of
this kind, and that it would be an illusion that you could
ever produce a complete list.


----------------------------------------------------------------------

Comment By: M.-A. Lemburg (lemburg)
Date: 2001-11-30 01:36

Message:
Logged In: YES 
user_id=38388

I disagree: any change which could potentially blow up existing programs should at least be mentioned somewhere 
in the docs, be it the NEWS file, the release page on python.org or (thanks to the great work of Andrew Kuchling) 
the "What's new in Python x.x" docs.

This is simply needed due to the very dynamic way Python works: there's no way to test all paths through a 
program if you want to port it from one Python version to the next, so we'll have to be very careful about these 
changes even if they are clearly bug fixes.

In the mentioned case, I'd say that the programmer was at fault, though: it's so much easier to test a path for being 
a directory than to rely on some obscure method return value and also much safer !

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2001-11-30 01:19

Message:
Logged In: YES 
user_id=21627

Any change is user-visible: for any change, I can construct
a program that behaves differently with the change.
Otherwise, the change would be useless (except that it may
add commentary or some such).

In fact, the change *is* documented, namely in the CVS log.
Extracting all those fragments into a single document would
be  time-consuming and pointless: nobody can read through
hundreds of changes.

Your program would have blown up even if there was such a
document. If a change has severe effects on many existing
programs, it should be implemented differently.

----------------------------------------------------------------------

Comment By: Gustavo Niemeyer (niemeyer)
Date: 2001-11-29 16:10

Message:
Logged In: YES 
user_id=7887

I think *any* change visible at user space should be 
documented. I discovered this change because a program I 
have never read in my life (in fact, I didn't even know it
was written in python) has blown up in my hands. It was
reading files and safely ignoring directories by testing
readline()'s output.



----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2001-11-29 15:53

Message:
Logged In: YES 
user_id=21627

I don't think this needs to be documented. The change is a
bug fix, reading from a directory was never supposed to work
(whether in lines or not).

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=487277&group_id=5470