cpython: 8e2388b1e875 (original) (raw)

Mercurial > cpython

changeset 94597:8e2388b1e875 2.7

Issue #21840: Fixed expanding unicode variables of form $var in posixpath.expandvars(). Fixed all os.path implementations on unicode-disabled builds. [#21840]

Serhiy Storchaka storchaka@gmail.com
date Fri, 13 Feb 2015 12:02:05 +0200
parents e55f955659bc
children 544c5d4f4084
files Lib/genericpath.py Lib/macpath.py Lib/ntpath.py Lib/os2emxpath.py Lib/posixpath.py Lib/test/test_genericpath.py Lib/test/test_macpath.py Lib/test/test_ntpath.py Lib/test/test_posixpath.py Misc/NEWS
diffstat 10 files changed, 52 insertions(+), 23 deletions(-)[+] [-] Lib/genericpath.py 8 Lib/macpath.py 3 Lib/ntpath.py 9 Lib/os2emxpath.py 3 Lib/posixpath.py 21 Lib/test/test_genericpath.py 2 Lib/test/test_macpath.py 1 Lib/test/test_ntpath.py 5 Lib/test/test_posixpath.py 19 Misc/NEWS 4

line wrap: on

line diff

--- a/Lib/genericpath.py +++ b/Lib/genericpath.py @@ -10,6 +10,14 @@ import stat 'getsize', 'isdir', 'isfile'] +try:

+except NameError:

+

Does a path exist?

This is false for dangling symbolic links on systems that support them.

def exists(path):

--- a/Lib/macpath.py +++ b/Lib/macpath.py @@ -5,6 +5,7 @@ import warnings from stat import * import genericpath from genericpath import * +from genericpath import _unicode all = ["normcase","isabs","join","splitdrive","split","splitext", "basename","dirname","commonprefix","getsize","getmtime", @@ -186,7 +187,7 @@ def walk(top, func, arg): def abspath(path): """Return an absolute path.""" if not isabs(path):

--- a/Lib/ntpath.py +++ b/Lib/ntpath.py @@ -12,6 +12,7 @@ import genericpath import warnings from genericpath import * +from genericpath import unicode all = ["normcase","isabs","join","splitdrive","split","splitext", "basename","dirname","commonprefix","getsize","getmtime", @@ -331,7 +332,7 @@ def expandvars(path): return path import string varchars = string.ascii_letters + string.digits + '-'

@@ -414,7 +415,7 @@ def expandvars(path): def normpath(path): """Normalize path, eliminating double slashes, etc.""" # Preserve unicode (if path is unicode)

@@ -471,7 +472,7 @@ except ImportError: # not running on Win def abspath(path): """Return the absolute version of a path.""" if not isabs(path):

@@ -487,7 +488,7 @@ else: # use native Windows method on Wi path = _getfullpathname(path) except WindowsError: pass # Bad path - return unchanged.

--- a/Lib/os2emxpath.py +++ b/Lib/os2emxpath.py @@ -8,6 +8,7 @@ module as os.path. import os import stat from genericpath import * +from genericpath import _unicode from ntpath import (expanduser, expandvars, isabs, islink, splitdrive, splitext, split, walk) @@ -146,7 +147,7 @@ def normpath(path): def abspath(path): """Return the absolute version of a path""" if not isabs(path):

--- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -16,14 +16,7 @@ import stat import genericpath import warnings from genericpath import * - -try:

-except NameError:

+from genericpath import _unicode all = ["normcase","isabs","join","splitdrive","split","splitext", "basename","dirname","commonprefix","getsize","getmtime", @@ -294,16 +287,16 @@ def expandvars(path): if '$' not in path: return path if isinstance(path, _unicode):

--- a/Lib/test/test_genericpath.py +++ b/Lib/test/test_genericpath.py @@ -243,11 +243,13 @@ class CommonTest(GenericTest): def test_realpath(self): self.assertIn("foo", self.pathmodule.realpath("foo"))

--- a/Lib/test/test_macpath.py +++ b/Lib/test/test_macpath.py @@ -59,6 +59,7 @@ class MacPathTestCase(unittest.TestCase) self.assertEqual(splitext(""), ('', '')) self.assertEqual(splitext("foo.bar.ext"), ('foo.bar', '.ext'))

--- a/Lib/test/test_ntpath.py +++ b/Lib/test/test_ntpath.py @@ -69,8 +69,9 @@ class TestNtpath(unittest.TestCase): ('', '\\conky\\mountpoint\foo\bar')) tester('ntpath.splitunc("//conky//mountpoint/foo/bar")', ('', '//conky//mountpoint/foo/bar'))

def test_split(self): tester('ntpath.split("c:\foo\bar")', ('c:\foo', 'bar'))

--- a/Lib/test/test_posixpath.py +++ b/Lib/test/test_posixpath.py @@ -1,7 +1,9 @@ import unittest from test import test_support, test_genericpath -import posixpath, os +import posixpath +import os +import sys from posixpath import realpath, abspath, dirname, basename

An absolute path to a temporary filename for testing. We can't rely on TESTFN

@@ -409,6 +411,21 @@ class PosixPathTest(unittest.TestCase): finally: os.getcwd = real_getcwd

+ class PosixCommonTest(test_genericpath.CommonTest): pathmodule = posixpath

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -18,6 +18,10 @@ Core and Builtins Library ------- +- Issue #21840: Fixed expanding unicode variables of form $var in