[New-bugs-announce] [issue10014] sys.path[0] is incorrect if PYTHONFSENCODING is used

STINNER Victor report at bugs.python.org
Sat Oct 2 14:14:23 CEST 2010


New submission from STINNER Victor <victor.stinner at haypocalc.com>:

In the following example, sys.path[0] should be '/home/SHARE/SVN/py3k\udcc3\udca9' (my locale and filesystem encodings are utf-8):

$ cd /home/SHARE/SVN/py3ké
$ echo "import sys; print(sys.path[0])" > x.py
$ ./python x.py
/home/SHARE/SVN/py3ké
$ PYTHONFSENCODING=ascii ./python x.py
/home/SHARE/SVN/py3ké

The problem is that PySys_SetArgvEx() inserts argv[0] at sys.path[0], but argv[0] is decoded using the locale encoding (by _Py_char2wchar() in main()), whereas paths of sys.path are supposed to be encodable (and decoded) by sys.getfilesystemencoding().

argv array should be decoded using the filesystem encoding (see issue #9992) or argv[0] should be redecoded (encode to the locale encoding, and decode from the filesystem encoding, see issue #9630).

----------
components: Unicode
messages: 117870
nosy: haypo
priority: normal
severity: normal
status: open
title: sys.path[0] is incorrect if PYTHONFSENCODING is used
versions: Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10014>
_______________________________________


More information about the New-bugs-announce mailing list