Closed dundee closed 7 years ago
Funcion warn expects first argument to be str only. If unicode containing some non-ascii symbols is passed, exception is raised.
>>> from warnings import warn >>> warn(u'řčš') Traceback (most recent call last): File "<input>", line 1, in <module> File "/usr/lib/python2.7/warnings.py", line 29, in _show_warning file.write(formatwarning(message, category, filename, lineno, line)) File "/usr/lib/python2.7/warnings.py", line 38, in formatwarning s = "%s:%s: %s: %s\n" % (filename, lineno, category.__name__, message) UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128) >>> warn(u'řčš'.encode('utf-8')) /usr/local/bin/bpython:2: UserWarning: řčš
Plain ascii strings are not affected by this fix:
>>> warn('aaa'.encode('utf-8')) /usr/local/bin/bpython:2: UserWarning: aaa
Funcion warn expects first argument to be str only. If unicode containing some non-ascii symbols is passed, exception is raised.
Plain ascii strings are not affected by this fix: