# HG changeset patch # User ja...py@farowl.co.uk # Date 1329003177 0 # Node ID ad749b17913ca9bb6d4fb647752e4ef0eb2b0dd2 # Parent 9c9c311c201b830a512b447e956c7f7d3e00d7b6 Issue 1837 fix. Replace use of os.path.samefile with path test in gderived.py, so it works on Windows diff -r 9c9c311c201b -r ad749b17913c src/templates/gderived.py --- a/src/templates/gderived.py Fri Feb 10 10:29:16 2012 -0800 +++ b/src/templates/gderived.py Sat Feb 11 23:32:57 2012 +0000 @@ -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()