summaryrefslogtreecommitdiffstats
path: root/Lib/pathlib.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2014-11-18 23:32:08 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2014-11-18 23:32:08 (GMT)
commitdb118f5db7ee8b52faf2c0bb32ed41e774609032 (patch)
treee8d0087a6542dabf43fd667c4df7806918cb2f69 /Lib/pathlib.py
parent81f68a7d4b36be360b1dd28e6cbb49a43dc8937b (diff)
downloadcpython-db118f5db7ee8b52faf2c0bb32ed41e774609032.zip
cpython-db118f5db7ee8b52faf2c0bb32ed41e774609032.tar.gz
cpython-db118f5db7ee8b52faf2c0bb32ed41e774609032.tar.bz2
Close #22370: Windows detection in pathlib is now more robust.
Diffstat (limited to 'Lib/pathlib.py')
-rw-r--r--Lib/pathlib.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/Lib/pathlib.py b/Lib/pathlib.py
index f5598c5..5d36364 100644
--- a/Lib/pathlib.py
+++ b/Lib/pathlib.py
@@ -15,16 +15,15 @@ from urllib.parse import quote_from_bytes as urlquote_from_bytes
supports_symlinks = True
-try:
+if os.name == 'nt':
import nt
-except ImportError:
- nt = None
-else:
if sys.getwindowsversion()[:2] >= (6, 0):
from nt import _getfinalpathname
else:
supports_symlinks = False
_getfinalpathname = None
+else:
+ nt = None
__all__ = [
@@ -110,7 +109,7 @@ class _WindowsFlavour(_Flavour):
has_drv = True
pathmod = ntpath
- is_supported = (nt is not None)
+ is_supported = (os.name == 'nt')
drive_letters = (
set(chr(x) for x in range(ord('a'), ord('z') + 1)) |