This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author davide.rizzo
Recipients akuchling, davide.rizzo, ezio.melotti, jesstess, mwh, neologix, sdaoden, vstinner
Date 2011-03-25.12:25:20
SpamBayes Score 3.330669e-16
Marked as misclassified No
Message-id <1301055921.48.0.889216626868.issue11650@psf.upfronthosting.co.za>
In-reply-to
Content
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?
History
Date User Action Args
2011-03-25 12:25:21davide.rizzosetrecipients: + davide.rizzo, mwh, akuchling, vstinner, ezio.melotti, jesstess, neologix, sdaoden
2011-03-25 12:25:21davide.rizzosetmessageid: <1301055921.48.0.889216626868.issue11650@psf.upfronthosting.co.za>
2011-03-25 12:25:20davide.rizzolinkissue11650 messages
2011-03-25 12:25:20davide.rizzocreate