[issue8754] ImportError: quote bad module name in message

STINNER Victor report at bugs.python.org
Thu Mar 24 00:18:53 CET 2011


STINNER Victor <victor.stinner at haypocalc.com> added the comment:

I patched import.c to use repr() instead of str() (%R instead of %U) to format module names because they might contain surrogate characters. Surrogate characters are not encodable to any encoding, except UTF-16 and UTF-32. And so print an exception to stdout may produce an UnicodeEncodeError. At the same time... exceptions are printed to stderr which uses the backslashreplace error handler, and so the message *can* be printed:

$ python3.1
>>> raise Exception('x\uDC80y')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
Exception: x\udc80y

So now I realized that my change was maybe useless.

----------
assignee: haypo -> eric.araujo

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


More information about the Python-bugs-list mailing list