Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

os.path.ismount() doesn't properly use byte-paths from an os.DirEntry #96192

Closed
Labels
3.10only security fixes3.11only security fixes3.12only security fixeseasystdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error
@calestyo

Description

@calestyo

Bug report

It seems thatos.path.ismount() doesn't properly use a bytes-path from anos.DirEntry object (despite both claiming to support/be PathLike).

Take e.g. the following code, when called with a bytespath:

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 NoneTypeError: Can't mix strings and bytes in path components

See alsohttps://discuss.python.org/t/bug-in-os-path-ismount-or-perhaps-os-direntry/18406

Your environment

  • CPython versions tested on: 3.10.6
  • Operating system and architecture: Debian sid, x86_64

Cheers,
Chris.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.10only security fixes3.11only security fixes3.12only security fixeseasystdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp