[New-bugs-announce] [issue19846] print() and write() are relying on sys.getfilesystemencoding() instead of sys.getdefaultencoding()
Sworddragon
report at bugs.python.org
Sat Nov 30 22:40:45 CET 2013
New submission from Sworddragon:
It seems that print() and write() (and maybe other of such I/O functions) are relying on sys.getfilesystemencoding(). But these functions are not operating with filenames but with their content. In the attachments is an example script which demonstrates this problem. Here is what I get:
sworddragon at ubuntu:~/tmp$ echo $LANG
de_DE.UTF-8
sworddragon at ubuntu:~/tmp$ python3 test.py
sys.getdefaultencoding(): utf-8
sys.getfilesystemencoding(): utf-8
ä
sworddragon at ubuntu:~/tmp$ LANG=C
sworddragon at ubuntu:~/tmp$ python3 test.py
sys.getdefaultencoding(): utf-8
sys.getfilesystemencoding(): ascii
Traceback (most recent call last):
File "test.py", line 4, in <module>
print('\xe4')
UnicodeEncodeError: 'ascii' codec can't encode character '\xe4' in position 0: ordinal not in range(128)
----------
components: IO
files: test.py
messages: 204849
nosy: Sworddragon
priority: normal
severity: normal
status: open
title: print() and write() are relying on sys.getfilesystemencoding() instead of sys.getdefaultencoding()
type: behavior
versions: Python 3.3
Added file: http://bugs.python.org/file32914/test.py
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19846>
_______________________________________
More information about the New-bugs-announce
mailing list