-
-
Notifications
You must be signed in to change notification settings - Fork 34.1k
Closed
Labels
3.10only security fixesonly security fixes3.11only security fixesonly security fixes3.12only security fixesonly security fixeseasystdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
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
Your environment
- CPython versions tested on: 3.10.6
- Operating system and architecture: Debian sid, x86_64
Cheers,
Chris.
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.10only security fixesonly security fixes3.11only security fixesonly security fixes3.12only security fixesonly security fixeseasystdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error