From: Raymond Hettinger Date: Sun, 6 Oct 2002 04:34:44 +0000 (+0000) Subject: Backport 1.45: X-Git-Tag: v2.2.2b1~37 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f29109aef18b8e4cbb395b55aaa532364a60778d;p=thirdparty%2FPython%2Fcpython.git Backport 1.45: Allow abspath to still do something sensisble if the nt module can not be imported. --- diff --git a/Lib/ntpath.py b/Lib/ntpath.py index 21fadd0eb9bd..5a63105d080b 100644 --- a/Lib/ntpath.py +++ b/Lib/ntpath.py @@ -457,8 +457,18 @@ def normpath(path): # Return an absolute path. def abspath(path): """Return the absolute version of a path""" - if path: # Empty path must return current working directory. + 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: