[Python-checkins] cpython (3.4): Close #22370: Windows detection in pathlib is now more robust.

antoine.pitrou python-checkins at python.org
Wed Nov 19 00:33:44 CET 2014


https://hg.python.org/cpython/rev/cb1d7eac601d
changeset: 93508:cb1d7eac601d
branch: 3.4
parent: 93505:342a619cdafb
user: Antoine Pitrou <solipsis at pitrou.net>
date: Wed Nov 19 00:32:08 2014 +0100
summary:
 Close #22370: Windows detection in pathlib is now more robust.
files:
 Lib/pathlib.py | 9 ++++-----
 Misc/NEWS | 2 ++
 2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/Lib/pathlib.py b/Lib/pathlib.py
--- 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)) |
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -36,6 +36,8 @@
 Library
 -------
 
+- Issue #22370: Windows detection in pathlib is now more robust.
+
 - Issue #22841: Reject coroutines in asyncio add_signal_handler().
 Patch by Ludovic.Gasc.
 
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /