diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-02-13 10:02:05 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-02-13 10:02:05 (GMT) |
commit | 2bd8b22b6de76851a7e36dc4a92d20930335ff57 (patch) | |
tree | 648a3e23f9a7d001b061930d3d07ef772de5477f /Lib/posixpath.py | |
parent | 4068b01cb55a66efca605d64b6e27d9fd7cebd3e (diff) | |
download | cpython-2bd8b22b6de76851a7e36dc4a92d20930335ff57.zip cpython-2bd8b22b6de76851a7e36dc4a92d20930335ff57.tar.gz cpython-2bd8b22b6de76851a7e36dc4a92d20930335ff57.tar.bz2 |
Issue #21840: Fixed expanding unicode variables of form $var in
posixpath.expandvars(). Fixed all os.path implementations on
unicode-disabled builds.
Diffstat (limited to 'Lib/posixpath.py')
-rw-r--r-- | Lib/posixpath.py | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/Lib/posixpath.py b/Lib/posixpath.py index 0378004..6578481 100644 --- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -16,14 +16,7 @@ import stat import genericpath import warnings from genericpath import * - -try: - _unicode = unicode -except NameError: - # If Python is built without Unicode support, the unicode type - # will not exist. Fake one. - class _unicode(object): - pass +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): - if not _varprog: + if not _uvarprog: import re - _varprog = re.compile(r'\$(\w+|\{[^}]*\})') - varprog = _varprog + _uvarprog = re.compile(ur'\$(\w+|\{[^}]*\})', re.UNICODE) + varprog = _uvarprog encoding = sys.getfilesystemencoding() else: - if not _uvarprog: + if not _varprog: import re - _uvarprog = re.compile(_unicode(r'\$(\w+|\{[^}]*\})'), re.UNICODE) - varprog = _uvarprog + _varprog = re.compile(r'\$(\w+|\{[^}]*\})') + varprog = _varprog encoding = None i = 0 while True: |