Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1d922d0

Browse files
committed
Close #22370: Windows detection in pathlib is now more robust.
2 parents 28c295f + db118f5 commit 1d922d0

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

Lib/pathlib.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@
1515

1616

1717
supports_symlinks = True
18-
try:
18+
if os.name == 'nt':
1919
import nt
20-
except ImportError:
21-
nt = None
22-
else:
2320
if sys.getwindowsversion()[:2] >= (6, 0):
2421
from nt import _getfinalpathname
2522
else:
2623
supports_symlinks = False
2724
_getfinalpathname = None
25+
else:
26+
nt = None
2827

2928

3029
__all__ = [
@@ -110,7 +109,7 @@ class _WindowsFlavour(_Flavour):
110109
has_drv = True
111110
pathmod = ntpath
112111

113-
is_supported = (nt is not None)
112+
is_supported = (os.name == 'nt')
114113

115114
drive_letters = (
116115
set(chr(x) for x in range(ord('a'), ord('z') + 1)) |

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ Core and Builtins
185185
Library
186186
-------
187187

188+
- Issue #22370: Windows detection in pathlib is now more robust.
189+
188190
- Issue #22841: Reject coroutines in asyncio add_signal_handler().
189191
Patch by Ludovic.Gasc.
190192

0 commit comments

Comments
 (0)