[New-bugs-announce] [issue29042] os.path.exists should not throw "Embedded NUL character" exception

Dolda2000 report at bugs.python.org
Wed Dec 21 23:36:28 EST 2016


New submission from Dolda2000:

Currently, calling os.path.exists on a path which contains NUL characters behaves consistently with most file-system calls by throwing an exception:

>>> os.path.exists('\0')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.5/genericpath.py", line 19, in exists
    os.stat(path)
ValueError: embedded null byte

However, os.path.exists is supposed to be a predicate returning whether there exists a file named by the path; it does not specify any particular method or system call for doing the test, and so reflecting the behavior of the underlying syscall used is not obviously desirable. A path containing an embedded NUL character simply cannot name an existing file, and therefore os.path.exists should return False for such a path.

----------
components: Library (Lib)
messages: 283807
nosy: Dolda2000
priority: normal
severity: normal
status: open
title: os.path.exists should not throw "Embedded NUL character" exception
type: behavior
versions: Python 3.5

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


More information about the New-bugs-announce mailing list