diff options
author | Mark Hammond <mhammond@skippinet.com.au> | 2002-01-17 00:44:26 (GMT) |
---|---|---|
committer | Mark Hammond <mhammond@skippinet.com.au> | 2002-01-17 00:44:26 (GMT) |
commit | f717f0500c468077d340e60ed17b0d40909c6d9c (patch) | |
tree | 7746a350aa31e5cabcdcddea0bc4c73d3f651d11 /Lib | |
parent | 39230b3230783d55fd5b21c0f745ab5eec366fa5 (diff) | |
download | cpython-f717f0500c468077d340e60ed17b0d40909c6d9c.zip cpython-f717f0500c468077d340e60ed17b0d40909c6d9c.tar.gz cpython-f717f0500c468077d340e60ed17b0d40909c6d9c.tar.bz2 |
Allow abspath to still do something sensisble if the nt module can not be imported.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/ntpath.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Lib/ntpath.py b/Lib/ntpath.py index 21fadd0..5a63105 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: |