]> granicus.if.org Git - python/commitdiff
Close #22370: Windows detection in pathlib is now more robust.
authorAntoine Pitrou <solipsis@pitrou.net>
Tue, 18 Nov 2014 23:32:08 +0000 (00:32 +0100)
committerAntoine Pitrou <solipsis@pitrou.net>
Tue, 18 Nov 2014 23:32:08 +0000 (00:32 +0100)
Lib/pathlib.py
Misc/NEWS

index f5598c51d2ec04e5ae5ee44c0e17b0e98d48828a..5d3636443eb82fac9cb73ba4c0da4e00a564b398 100644 (file)
@@ -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)) |
index 6a4b81f54bf645c7891e148ece5143792858a39c..275e8590dee5704378db5bd73627de6a68d26467 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -36,6 +36,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #22370: Windows detection in pathlib is now more robust.
+
 - Issue #22841: Reject coroutines in asyncio add_signal_handler().
   Patch by Ludovic.Gasc.