summaryrefslogtreecommitdiffstats
path: root/Lib/ntpath.py
diff options
context:
space:
mode:
authorBrian Curtin <brian.curtin@gmail.com>2010-09-24 13:56:34 (GMT)
committerBrian Curtin <brian.curtin@gmail.com>2010-09-24 13:56:34 (GMT)
commite8e8042bb5f722481ce22be573e62a6d009c7dfe (patch)
tree00e4e6be675f86cc80c3ef31e42eda00f9149c10 /Lib/ntpath.py
parent0151b8eddada4062b9efc18fffe87956fd90db09 (diff)
downloadcpython-e8e8042bb5f722481ce22be573e62a6d009c7dfe.zip
cpython-e8e8042bb5f722481ce22be573e62a6d009c7dfe.tar.gz
cpython-e8e8042bb5f722481ce22be573e62a6d009c7dfe.tar.bz2
Fix #9790 again. Rather than handle NotImplementedError at runtime as
before, only attempt the import where nt._getfinalpathname could actually work, i.e., Windows Vista and beyond.
Diffstat (limited to 'Lib/ntpath.py')
-rw-r--r--Lib/ntpath.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/Lib/ntpath.py b/Lib/ntpath.py
index 6d1b50a..d2410f6 100644
--- a/Lib/ntpath.py
+++ b/Lib/ntpath.py
@@ -642,12 +642,17 @@ def relpath(path, start=curdir):
# determine if two files are in fact the same file
try:
- from nt import _getfinalpathname
-except (NotImplementedError, ImportError):
+ # GetFinalPathNameByHandle is available starting with Windows 6.0.
+ # Windows XP and non-Windows OS'es will mock _getfinalpathname.
+ if sys.getwindowsversion()[:2] >= (6, 0):
+ from nt import _getfinalpathname
+ else:
+ raise ImportError
+except (AttributeError, ImportError):
# On Windows XP and earlier, two files are the same if their absolute
# pathnames are the same.
- # Also, on other operating systems, fake this method with a
- # Windows-XP approximation.
+ # Non-Windows operating systems fake this method with an XP
+ # approximation.
def _getfinalpathname(f):
return abspath(f)