Kaydet (Commit) 823e91c7 authored tarafından Guido van Rossum's avatar Guido van Rossum

Optimize abspath() slightly for the case that win32api can't be

imported; in that case, abspath is replaced by a fallback version.
üst 5606801b
...@@ -403,11 +403,16 @@ def abspath(path): ...@@ -403,11 +403,16 @@ def abspath(path):
"""Return the absolute version of a path""" """Return the absolute version of a path"""
try: try:
import win32api import win32api
try:
path = win32api.GetFullPathName(path)
except win32api.error:
pass # Bad path - return unchanged.
except ImportError: except ImportError:
if not isabs(path): global abspath
path = join(os.getcwd(), path) def _abspath(path):
if not isabs(path):
path = join(os.getcwd(), path)
return normpath(path)
abspath = _abspath
return _abspath(path)
try:
path = win32api.GetFullPathName(path)
except win32api.error:
pass # Bad path - return unchanged.
return normpath(path) return normpath(path)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment