GH-117546: Fix symlink resolution in os.path.realpath('loop/../link') (#117568)

Continue resolving symlink targets after encountering a symlink loop, which
matches coreutils `realpath` behaviour.
This commit is contained in:
Barney Gale 2024-04-10 18:17:18 +01:00 committed by GitHub
parent 6bc0b33a91
commit 630df37116
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 7 additions and 17 deletions

View file

@ -484,7 +484,7 @@ class PosixPathTest(unittest.TestCase):
self.assertEqual(realpath(ABSTFN+"1/../x"), dirname(ABSTFN) + "/x")
os.symlink(ABSTFN+"x", ABSTFN+"y")
self.assertEqual(realpath(ABSTFN+"1/../" + basename(ABSTFN) + "y"),
ABSTFN + "y")
ABSTFN + "x")
self.assertEqual(realpath(ABSTFN+"1/../" + basename(ABSTFN) + "1"),
ABSTFN + "1")