[issue23637] Warnings error with non-ascii chars.
Serhiy Storchaka
report at bugs.python.org
Fri Mar 13 19:48:19 CET 2015
Serhiy Storchaka added the comment:
The problem is not only with the file.write(). If one of arguments is unicode (even if it doesn't contain non-ascii characters) and other argument is non-ascii string, we get this error.
>>> warnings.showwarning(u'', DeprecationWarning, 'filè.py', 10)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/serhiy/py/cpython-2.7/Lib/warnings.py", line 33, in _show_warning
file.write(formatwarning(message, category, filename, lineno, line))
File "/home/serhiy/py/cpython-2.7/Lib/warnings.py", line 42, in formatwarning
s = "%s:%s: %s: %s\n" % (filename, lineno, category.__name__, message)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3: ordinal not in range(128)
Non-ascii file names are rare, and unicode warnings are rare, that is why this bug was not fixed before. I think it is worth to fix. It is better to output modified warning (e.g. backslashescaped) than fail without clear diagnostic.
----------
nosy: +serhiy.storchaka
resolution: not a bug ->
stage: resolved ->
status: closed -> open
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23637>
_______________________________________
More information about the Python-bugs-list
mailing list