[issue11650] Faulty RESTART/EINTR handling in Parser/myreadline.c
Davide Rizzo
report at bugs.python.org
Fri Mar 25 13:25:21 CET 2011
Davide Rizzo <sorcio at gmail.com> added the comment:
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?
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11650>
_______________________________________
More information about the Python-bugs-list
mailing list