summaryrefslogtreecommitdiffstats
path: root/Lib/ntpath.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/ntpath.py')
-rw-r--r--Lib/ntpath.py43
1 files changed, 22 insertions, 21 deletions
diff --git a/Lib/ntpath.py b/Lib/ntpath.py
index 5dd5f1a..7a79b53 100644
--- a/Lib/ntpath.py
+++ b/Lib/ntpath.py
@@ -481,27 +481,28 @@ def normpath(path):
# Return an absolute path.
-def abspath(path):
- """Return the absolute version of a path"""
- try:
- from nt import _getfullpathname
- except ImportError: # Not running on Windows - mock up something sensible.
- 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.
- try:
- path = _getfullpathname(path)
- except WindowsError:
- pass # Bad path - return unchanged.
- else:
- path = os.getcwd()
- return normpath(path)
+try:
+ from nt import _getfullpathname
+
+except ImportError: # not running on Windows - mock up something sensible
+ def abspath(path):
+ """Return the absolute version of a path."""
+ if not isabs(path):
+ path = join(os.getcwd(), path)
+ return normpath(path)
+
+else: # use native Windows method on Windows
+ def abspath(path):
+ """Return the absolute version of a path."""
+
+ if path: # Empty path must return current working directory.
+ try:
+ path = _getfullpathname(path)
+ except WindowsError:
+ pass # Bad path - return unchanged.
+ else:
+ path = os.getcwd()
+ return normpath(path)
# realpath is a no-op on systems without islink support
realpath = abspath