Close #22370: Windows detection in pathlib is now more robust.
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 @@
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 @@
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)) |