-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
os.path.realpath
raises a ValueError
when path contains a null byte
#117596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I already created a PR #117573 for this issue |
I do not think there is a bug. Functions like
|
In case of I guess my selection of examples was not very good. I would except consistency across all path operations, but I found only Python 3.13.0a5+ (heads/fix-realpath-value-error-dirty:8da4ebb996, Apr 7 2024, 17:05:12) [GCC 13.2.1 20230918 (Red Hat 13.2.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.fspath("\x00")
'\x00'
>>> os.path.abspath("\x00")
'/var/home/stefan/Development/repos/cpython/\x00'
>>> os.path.basename("\x00")
'\x00'
>>> os.path.dirname("\x00")
''
>>> os.path.relpath("\x00")
'\x00'
>>> os.path.normpath("\x00")
'\x00'
>>> |
|
Serhiy's model sounds good to me. To summarize:
But, it looks like that's not what we do on Windows. |
Bug report
Bug description:
The
ValueError
is initially raised byos.lstat
.This behavior is inconsistent with other path operations catching the
ValueError
raised byos.lstat
:os.path.lexsists
: https://github.com/python/cpython/blob/main/Lib/genericpath.py#L30os.path.exists
: https://github.com/python/cpython/blob/main/Lib/genericpath.py#L20os.path.islink
: https://github.com/python/cpython/blob/main/Lib/genericpath.py#L64os.path.ismount
: https://github.com/python/cpython/blob/main/Lib/posixpath.py#L197os.path.ismount
: https://github.com/python/cpython/blob/main/Lib/posixpath.py#L213CPython versions tested on:
3.10, CPython main branch
Operating systems tested on:
Linux
Linked PRs
The text was updated successfully, but these errors were encountered: