mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Add support for Windows using "mbcs" as the default Unicode encoding when dealing with the file system. As discussed on python-dev and in patch 410465.
This commit is contained in:
parent
342c65e19a
commit
ef8b654bbe
7 changed files with 197 additions and 56 deletions
|
@ -404,21 +404,12 @@ def normpath(path):
|
|||
# Return an absolute path.
|
||||
def abspath(path):
|
||||
"""Return the absolute version of a path"""
|
||||
try:
|
||||
import win32api
|
||||
except ImportError:
|
||||
global abspath
|
||||
def _abspath(path):
|
||||
if not isabs(path):
|
||||
path = join(os.getcwd(), path)
|
||||
return normpath(path)
|
||||
abspath = _abspath
|
||||
return _abspath(path)
|
||||
if path: # Empty path must return current working directory.
|
||||
from nt import _getfullpathname
|
||||
try:
|
||||
path = win32api.GetFullPathName(path)
|
||||
except win32api.error:
|
||||
pass # Bad path - return unchanged.
|
||||
path = _getfullpathname(path)
|
||||
except WindowsError:
|
||||
pass # Bad path - return unchanged.
|
||||
else:
|
||||
path = os.getcwd()
|
||||
return normpath(path)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue