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:
Mark Hammond 2001-05-13 08:04:26 +00:00
parent 342c65e19a
commit ef8b654bbe
7 changed files with 197 additions and 56 deletions

View file

@ -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)