Antoine Pitrou <pit...@free.fr> added the comment: > 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 sys.stdin.read(), 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") >>> sys.stdin.read() héhé 'h��h��\n' >>> input() héhé 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 sys.stdin.read() directly. ---------- components: +Interpreter Core -Unicode nosy: +pitrou stage: -> needs patch versions: -Python 3.4 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue13342> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com