cpython: c5f4fa02fc86 (original) (raw)

Mercurial > cpython

changeset 82119:c5f4fa02fc86 3.2

Issue #6975: os.path.realpath() now correctly resolves multiple nested symlinks on POSIX platforms. [#6975]

Serhiy Storchaka storchaka@gmail.com
date Sun, 10 Feb 2013 12:22:07 +0200
parents 38830281d43b
children bfe9526606e2 66f92f76b2ce
files Lib/posixpath.py Lib/test/test_posixpath.py Misc/NEWS
diffstat 3 files changed, 105 insertions(+), 39 deletions(-)[+] [-] Lib/posixpath.py 86 Lib/test/test_posixpath.py 55 Misc/NEWS 3

line wrap: on

line diff

--- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -390,51 +390,59 @@ def abspath(path): def realpath(filename): """Return the canonical path of the specified filename, eliminating any symbolic links encountered in the path."""

+ +# Join two paths, normalizing ang eliminating any symbolic links +# encountered in the second path. +def _joinrealpath(path, rest, seen):

-

-def _resolve_link(path):

+ supports_unicode_filenames = (sys.platform == 'darwin')

--- a/Lib/test/test_posixpath.py +++ b/Lib/test/test_posixpath.py @@ -375,6 +375,22 @@ class PosixPathTest(unittest.TestCase): self.assertEqual(realpath(ABSTFN+"1"), ABSTFN+"1") self.assertEqual(realpath(ABSTFN+"2"), ABSTFN+"2")

+

+

+ # Test using relative path as well. os.chdir(dirname(ABSTFN)) self.assertEqual(realpath(basename(ABSTFN)), ABSTFN) @@ -383,6 +399,45 @@ class PosixPathTest(unittest.TestCase): support.unlink(ABSTFN) support.unlink(ABSTFN+"1") support.unlink(ABSTFN+"2")

+

+

+

@unittest.skipUnless(hasattr(os, "symlink"), "Missing symlink implementation")

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -218,6 +218,9 @@ Core and Builtins Library ------- +- Issue #6975: os.path.realpath() now correctly resolves multiple nested