]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
GH-118289: Fix handling of non-directories in `posixpath.realpath()` (#120127)
authorBarney Gale <barney.gale@gmail.com>
Wed, 13 Nov 2024 22:59:32 +0000 (22:59 +0000)
committerGitHub <noreply@github.com>
Wed, 13 Nov 2024 22:59:32 +0000 (22:59 +0000)
commitfd4b5453df74e249987553b12c14ad75fafa4991
treebffc6a81cdd6a05b097468aedf6b9206944d61eb
parentc695e37a3f95c225ee08d1e882d23fa200b5ec34
GH-118289: Fix handling of non-directories in `posixpath.realpath()` (#120127)

In strict mode, raise `NotADirectoryError` if we encounter a non-directory
while we still have path parts left to process.

We use a `part_count` variable rather than `len(rest)` because the `rest`
stack also contains markers for unresolved symlinks.
Lib/posixpath.py
Lib/test/test_posixpath.py
Misc/NEWS.d/next/Library/2024-06-05-19-09-36.gh-issue-118289.moL9_d.rst [new file with mode: 0644]