STINNER Victor <victor.stin...@haypocalc.com> added the comment:

Attached patch creates PySys_AddWarnOptionUnicode() function and decodes 
PYTHONWARNINGS variable with the file system encoding (as it is done for 
os.environ, to be consistent) instead of the locale encoding.

The patch only concerns the POSIX version. Windows is not affected by this 
issue (see below).

--

This issue occurs if the file system encoding is different than the locale 
encoding (especially if the locale encoding is ASCII). It only occurs on Mac OS 
because on this OS, the file system encoding is hardcoded to UTF-8 whereas the 
locale encoding... depends on the locale.

I reproduced the bug on Linux by hardcoding the file system encoding to UTF-8.

--

About the test output (UnicodeEncodeError: 'ascii' codec can't encode character 
'\xf3' ...): I think that Michael Foord executed directly 
Lib/test/test_warnings.py instead of using "Lib/test/regrtest.py -v 
test_warnings". I only patched regrtest.py to use backslashreplace error 
handler on sys.stdout.

----------
keywords: +patch
Added file: http://bugs.python.org/file17389/sys_warnoptions_encoding.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue8589>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to