This simple python program: ------------------------------- raise Exception(u'Muri\u00f3') ------------------------------- prints: ----------------------------------- Traceback (most recent call last): File "pylog.py", line 1, in ? raise Exception(u'Muri\u00f3') Exception ----------------------------------- While not using an unicode character, seems to work fine (even if using an unicode parameter): -------------------------- raise Exception(u'Murio') -------------------------- prints: ----------------------------------- Traceback (most recent call last): File "pylog.py", line 1, in ? raise Exception(u'Murio') Exception: Murio ----------------------------------- This seems to break the logging module when calling logging.exception(u'Muri\u00f3'), for example. Tested in Python 2.4.4 and 2.5 (debian).
That's from line 1216-1230 of Python/pythonrun.c as in trunk. It tries PyObject_Str(exception) and skips printing line terminator when it failed. And the behavior came from r8084 (http://svn.python.org/view/python/trunk/Python/pythonrun.c?rev=8084&r1=8070&r2=8084). Hmm. I think it should put a LF even if the conversion failed. (encoding the unicode with "ignore" or "replace" would make some confusion and putting it in PyObject_Repr() makes inconsistency.)
I fixed the "prints no newline" problem in rev. 54288. There's nothing sensible we can do about the unicode conversion, so closing as "won't fix". You should always encode or repr() unicode exception arguments.