[Python-checkins] benchmarks: Update pathlib copy to fix compatibility with Windows under Python 2.7

antoine.pitrou python-checkins at python.org
Tue Jul 24 21:39:23 CEST 2012


http://hg.python.org/benchmarks/rev/917a9950b4b1
changeset:   159:917a9950b4b1
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Tue Jul 24 21:37:10 2012 +0200
summary:
  Update pathlib copy to fix compatibility with Windows under Python 2.7

files:
  lib/pathlib/pathlib.py |  8 ++++++--
  1 files changed, 6 insertions(+), 2 deletions(-)


diff --git a/lib/pathlib/pathlib.py b/lib/pathlib/pathlib.py
--- a/lib/pathlib/pathlib.py
+++ b/lib/pathlib/pathlib.py
@@ -24,7 +24,7 @@
 except ImportError:
     nt = None
 else:
-    if sys.getwindowsversion()[:2] >= (6, 0):
+    if sys.getwindowsversion()[:2] >= (6, 0) and sys.version_info >= (3, 2):
         from nt import _getfinalpathname
     else:
         supports_symlinks = False
@@ -481,7 +481,11 @@
     rename = _wrap_binary_strfunc(os.rename)
 
     if nt:
-        symlink = _wrap_binary_strfunc(os.symlink)
+        if supports_symlinks:
+            symlink = _wrap_binary_strfunc(os.symlink)
+        else:
+            def symlink(a, b, target_is_directory):
+                raise NotImplementedError("symlink() not available on this system")
     else:
         # Under POSIX, os.symlink() takes two args
         @staticmethod

-- 
Repository URL: http://hg.python.org/benchmarks


More information about the Python-checkins mailing list