]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.13] GH-118289: Fix handling of non-directories in `posixpath.realpath()` (GH...
authorBarney Gale <barney.gale@gmail.com>
Wed, 13 Nov 2024 23:32:56 +0000 (23:32 +0000)
committerGitHub <noreply@github.com>
Wed, 13 Nov 2024 23:32:56 +0000 (23:32 +0000)
commitb66728da05e2f959eafb46df94d240ac801e8a3e
tree335d7db9e2ee2f0dd2db411d858840c279130358
parentad1b23bf29aaa80310a00ebc6ba8d485724c6724
[3.13] GH-118289: Fix handling of non-directories in `posixpath.realpath()`  (GH-120127) (#126815)

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.
(cherry picked from commit fd4b5453df74e249987553b12c14ad75fafa4991)
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]