Message238047
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. |
|
Date |
User |
Action |
Args |
2015-03-13 18:48:19 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, ezio.melotti, r.david.murray, Lukáš.Němec |
2015-03-13 18:48:19 | serhiy.storchaka | set | messageid: <1426272499.83.0.985827448581.issue23637@psf.upfronthosting.co.za> |
2015-03-13 18:48:19 | serhiy.storchaka | link | issue23637 messages |
2015-03-13 18:48:19 | serhiy.storchaka | create | |
|