cpython: f42cabe6ccb5 (original) (raw)

Mercurial > cpython

changeset 82121:f42cabe6ccb5

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:24:06 +0200
parents bd6a2fcc7711(current diff)bfe9526606e2(diff)
children 12d75ca12ae7
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 @@ -363,51 +363,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 @@ -320,6 +320,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) @@ -328,6 +344,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 @@ -244,6 +244,9 @@ Core and Builtins Library ------- +- Issue #6975: os.path.realpath() now correctly resolves multiple nested