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 <[email protected]>
<http://bugs.python.org/issue23637>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com