[issue14200] Idle shell crash on printing non-BMP unicode character

Martin v. Löwis report at bugs.python.org
Tue Mar 6 19:53:25 CET 2012


Martin v. Löwis <martin at v.loewis.de> added the comment:

That pythonw suddenly closes is a separate issue: if pythonw attempts to write to stderr, it crashes. To get your example to "run" in pythonw.exe,
try

pythonw.exe Lib\idlelib\idle.py 2> out.txt

I think the behavior of pythonw terminating when it can't write to stderr is actually correct: an exception is raised on attempting to write to stderr, which then can be printed (because there is no stderr).

So the real fault here is the traceback that python.exe reports.

To fix this, I think rpc.py should learn to marshal exceptions back to the subprocess. Then the initial sys.stdout.write should raise a UnicodeError (which it currently doesn't, either). This would get into the displayhook, which would then run use sys_displayhook_unencodable to backslashescape the unsupported character.

I'll attach a patch that at least makes the exception UnicodeEncodeError.

----------
keywords: +patch
Added file: http://bugs.python.org/file24748/unicodeerror.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14200>
_______________________________________


More information about the Python-bugs-list mailing list