From: Antoine Pitrou Date: Tue, 18 Nov 2014 23:32:08 +0000 (+0100) Subject: Close #22370: Windows detection in pathlib is now more robust. X-Git-Tag: v3.5.0a1~473^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=db118f5db7ee8b52faf2c0bb32ed41e774609032;p=python Close #22370: Windows detection in pathlib is now more robust. --- diff --git a/Lib/pathlib.py b/Lib/pathlib.py index f5598c51d2..5d3636443e 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)) | diff --git a/Misc/NEWS b/Misc/NEWS index 6a4b81f54b..275e8590de 100644 --- 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.