You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
os.path.ismount() doesn't properly use byte-paths from an os.DirEntry #96192
It seems that os.path.ismount() doesn't properly use a bytes-path from an os.DirEntry object (despite both claiming to support/be PathLike).
Take e.g. the following code, when called with a bytes path:
def scandirtree(path=b".", xdev=True):
for p in os.scandir(path):
yield p
if p.is_dir(follow_symlinks=False) and ( not xdev or not os.path.ismount(p) ):
yield from scandirtree(p, xdev)
That fails with:
Traceback (most recent call last):
File "/home/calestyo/prj/generate-file-list/src/./generate-file-list", line 65, in <module>
main()
File "/home/calestyo/prj/generate-file-list/src/./generate-file-list", line 52, in main
for p in scandirtree(ap, args.xdev):
File "/home/calestyo/prj/generate-file-list/src/./generate-file-list", line 25, in scandirtree
if p.is_dir(follow_symlinks=False) and ( not xdev or not os.path.ismount(p) ):
File "/usr/lib/python3.10/posixpath.py", line 201, in ismount
parent = join(path, '..')
File "/usr/lib/python3.10/posixpath.py", line 90, in join
genericpath._check_arg_types('join', a, *p)
File "/usr/lib/python3.10/genericpath.py", line 155, in _check_arg_types
raise TypeError("Can't mix strings and bytes in path components") from None
TypeError: Can't mix strings and bytes in path components
Activity
eryksun commentedon Aug 23, 2022
posixpath.ismount()mistakenly checksisinstance(path, bytes)without first ensuring that the type isstrorbytesviapath = os.fspath(path).calestyo commentedon Aug 23, 2022
Shall I provide a patch?
gh-96192: fix os.ismount() to use a path that is str or bytes (#96194)
pythongh-96192: fix os.ismount() to use a path that is str or bytes (p…
pythongh-96192: fix os.ismount() to use a path that is str or bytes (p…
hauntsaninja commentedon Nov 29, 2022
Thanks, looks like this has been fixed!
gh-96192: fix os.ismount() to use a path that is str or bytes (GH-96194)
[3.10] gh-96192: fix os.ismount() to use a path that is str or bytes (G…