[Jython-checkins] jython (2.5): #1837 Backport gderived.py fix for Windows to 2.5. Thanks Jeff Allen!

frank.wierzbicki jython-checkins at python.org
Thu Mar 29 22:50:25 CEST 2012


http://hg.python.org/jython/rev/c7f648b3e03a
changeset:   6504:c7f648b3e03a
branch:      2.5
parent:      6501:bf3ed36e65bd
user:        Frank Wierzbicki <fwierzbicki at gmail.com>
date:        Thu Mar 29 13:49:48 2012 -0700
summary:
  #1837 Backport gderived.py fix for Windows to 2.5. Thanks Jeff Allen!

files:
  NEWS                      |   1 +
  src/templates/gderived.py |  13 +++++++++++--
  2 files changed, 12 insertions(+), 2 deletions(-)


diff --git a/NEWS b/NEWS
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@
 
 Jython 2.5.3b2
   Bugs Fixed
+    - [ 1837 ] gderived.py and template Ant target fail on Windows
     - [ 1536 ] NPE in org.python.jsr223.PyScriptEngine:187
     - [ 1640 ] cStringIO does not complain on getvalue after close
     - [ 1721 ] NPE when using JSR 223 (TestCase+Patch)
diff --git a/src/templates/gderived.py b/src/templates/gderived.py
--- a/src/templates/gderived.py
+++ b/src/templates/gderived.py
@@ -23,6 +23,15 @@
 
 modif_re = re.compile(r"(?:\((\w+)\))?(\w+)")
 
+# os.path.samefile unavailable on Windows before Python v3.2
+if hasattr(os.path,"samefile"):
+    # Good: available on this platform
+    os_path_samefile = os.path.samefile
+else:
+    def os_path_samefile(a,b):
+        'Files are considered the same if their absolute paths are equal'
+        return os.path.abspath(a)==os.path.abspath(b)
+
 class Gen:
 
     priority_order = ['require','define','base_class',
@@ -212,7 +221,7 @@
     org.python.core
     """
     parent = os.path.dirname(fn)
-    if os.path.samefile(parent, core_dir):
+    if os_path_samefile(parent, core_dir):
         return result
 
     print 'Fixing header for: %s' % fn
@@ -220,7 +229,7 @@
     while True:
         parent, tail = os.path.split(parent)
         dirs.insert(0, tail)
-        if os.path.samefile(parent, org_python_dir) or not tail:
+        if os_path_samefile(parent, org_python_dir) or not tail:
             break
 
     result = result.splitlines()

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


More information about the Jython-checkins mailing list