[issue29042] os.path.exists should not throw "Embedded NUL character" exception
Christoph Reiter
report at bugs.python.org
Thu Dec 22 03:54:01 EST 2016
Christoph Reiter added the comment:
Raising in case no valid path is passed seems fine to me. There are other cases where it fails:
python3 -c "import os; os.path.exists('\ud83d')"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.5/genericpath.py", line 19, in exists
os.stat(path)
UnicodeEncodeError: 'utf-8' codec can't encode character '\ud83d' in position 0: surrogates not allowed
LANG=C python3 -c "import os; os.path.exists('\xff')" ~
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.5/genericpath.py", line 19, in exists
os.stat(path)
UnicodeEncodeError: 'ascii' codec can't encode character '\xff' in position 0: ordinal not in range(128)
----------
nosy: +lazka
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29042>
_______________________________________
More information about the Python-bugs-list
mailing list