Repository navigation
gh-160506: Fix ntpath.realpath() for broken links via directory links - #160507
Conversation
… links Resolve the directory containing a broken relative symlink before joining the link target to it, so that '..' in the target is applied to the real directory. ANT-2026-27II3A20
|
!buildbot windows |
|
🤖 New build scheduled with the buildbot fleet by @gpshead for commit 5dbdc22 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F160507%2Fmerge The command will test the builders whose names match following regular expression: The builders matched are:
|
|
Thanks @gpshead for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12, 3.13, 3.14, 3.15. |
|
GH-161026 is a backport of this pull request to the 3.15 branch. |
|
GH-161027 is a backport of this pull request to the 3.14 branch. |
|
GH-161028 is a backport of this pull request to the 3.13 branch. |
|
GH-161029 is a backport of this pull request to the 3.12 branch. |
|
GH-161030 is a backport of this pull request to the 3.11 branch. |
…y links (GH-160507) (#161026) gh-160506: Fix ntpath.realpath() for broken links via directory links (GH-160507) Resolve the directory containing a broken relative symlink before joining the link target to it, so that '..' in the target is applied to the real directory. ANT-2026-27II3A20 (cherry picked from commit 65665a4) Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
…y links (GH-160507) (#161027) gh-160506: Fix ntpath.realpath() for broken links via directory links (GH-160507) Resolve the directory containing a broken relative symlink before joining the link target to it, so that '..' in the target is applied to the real directory. ANT-2026-27II3A20 (cherry picked from commit 65665a4) Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
ntpath._readlink_deep(), the fallbackrealpath()uses for a link Windows cannot open, now resolves the directory that contains the link with_getfinalpathname()before joining a relative target to it, so..in the target goes up from the real directory. It keeps the textual join only if that directory cannot be resolved with one of the error codes the function already tolerates. Two expectations intest_realpath_broken_symlinkschange (broken2andbroken3now resolve toABSTFN\missing), because they asserted the unresolved join.I could not run this on Windows: the changed branch and the
test_ntpathtests are skipped on Linux, where I only exercised the code over stand-ins for thentfunctions. It needs the Windows CI run before review.test_parent_symlink3intest_tarfilepasses on Linux with and without the change; its Windows branch is the one that depends on it.Fixes #160506
ANT-2026-27II3A20
os.path.realpath()on Windows misresolves a broken symlink reached through a directory symlink #160506