Message132081
The bugs seems not to be limited to the REPL.
# Python 2.6 with readline on Mac OS X
$ python -c "raw_input()"
^Z
[1]+ Stopped python -c "raw_input()"
$ fg
python -c "raw_input()"
Traceback (most recent call last):
File "<string>", line 1, in <module>
EOFError
# Python 3.1 on Debian Linux
$ python3.1 -c "print(input())"
^Z
[1]+ Stopped python3.1 -c "print(input())"
$ fg
python3.1 -c "print(input())"
hello
hello
# Python 3.3(267578b2422d) without readline, OS X (I've put two extra printfs around fgets in myreadline.c)
$ ./python.exe -c "print(input())"
Entering fgets
^Z
[1]+ Stopped ./python.exe -c "print(input())"
$ fg
./python.exe -c "print(input())"
fgets returned 0
Traceback (most recent call last):
File "<string>", line 1, in <module>
EOFError
[36537 refs]
# same as before with Charles-Francois patch applied
$ ./python.exe -c "print(input())"
^Z
[1]+ Stopped ./python.exe -c "print(input())"
$ fg
./python.exe -c "print(input())"
hello
hello
[36538 refs]
Some remarks here:
1) the bug is in all tested versions running on OS X, and the patch does fix it.
2) I tested with and without GNU readline and input()'s behavior doesn't change when running with python -c (i.e. it uses myreadline.c instead of GNU readline). Though, if run interactively, input() uses readline.
Isn't input() supposed to use readline whenever reading from a tty, not only if called from the REPL? Or even if it were to fallback, shouldn't that be on TextIOWrapper(sys.stdin).readline()?
3) io module seems to be doing it right already. sys.stdin.read() raises an IOError (not an EOFError as input() incorrectly does, this is acceptable as a platform quirk) when interrupted, while sys.stdin.readline() handles the interruption without complaining at all.
Maybe myreadline.c is too old and wants to be replaced (or backed) by io in 3.3? |
|
Date |
User |
Action |
Args |
2011-03-25 12:25:21 | davide.rizzo | set | recipients:
+ davide.rizzo, mwh, akuchling, vstinner, ezio.melotti, jesstess, neologix, sdaoden |
2011-03-25 12:25:21 | davide.rizzo | set | messageid: <1301055921.48.0.889216626868.issue11650@psf.upfronthosting.co.za> |
2011-03-25 12:25:20 | davide.rizzo | link | issue11650 messages |
2011-03-25 12:25:20 | davide.rizzo | create | |
|