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 pitrou
Recipients benjamin.peterson, ezio.melotti, pitrou, stefanholek
Date 2011-11-04.15:06:18
SpamBayes Score 1.6653345e-16
Marked as misclassified No
Message-id <>
> There cannot be a reason input() should be confined to "strict", or can 
> there? ;-)

Actually, there's a good reason: in the non-interactive case, input() simply calls, which doesn't have encoding or errors attributes. You want to override sys.stdin so that it has the right error handler.

However, there is a bug in input() in that it ignores sys.stdin's error handler in interactive mode (where it delegates to the readline library, if present):

>>> import sys, io
>>> sys.stdin = io.TextIOWrapper(sys.stdin.detach(), "ascii", "replace")
>>> input()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)

If you don't mind losing GNU readline functionality, the immediate workaround for you is to use directly.
Date User Action Args
2011-11-04 15:06:20pitrousetrecipients: + pitrou, benjamin.peterson, ezio.melotti, stefanholek
2011-11-04 15:06:20pitrousetmessageid: <>
2011-11-04 15:06:19pitroulinkissue13342 messages
2011-11-04 15:06:18pitroucreate