Compensate for an os.path.normpath('./') bug on Win32. (Charles Crain)
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Thu, 31 Jan 2002 21:44:11 +0000 (21:44 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Thu, 31 Jan 2002 21:44:11 +0000 (21:44 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@238 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Node/FS.py
src/engine/SCons/Node/FSTests.py

index f07d51d942ae6b397bf2994a87157e42e03d2cea..55084364e33c5efe39c545d0710185c5ae3ef3d4 100644 (file)
@@ -136,6 +136,18 @@ class FS:
        relative path with directory=None, then an AssertionError will be
        raised."""
 
+        if not name:
+            # This is a stupid hack to compensate for the fact
+            # that the POSIX and Win32 versions of os.path.normpath()
+            # behave differently.  In particular, in POSIX:
+            #   os.path.normpath('./') == '.'
+            # in Win32
+            #   os.path.normpath('./') == ''
+            #   os.path.normpath('.\\') == ''
+            #
+            # This is a definite bug in the Python library, but we have
+            # to live with it.
+            name = '.'
         path_comp = string.split(name, os.sep)
         drive, path_first = os.path.splitdrive(path_comp[0])
         if not path_first:
index 03a8727a981eeb43db71025e9897115d61d214f3..f20c2fb922c03f826b3e344d649da22065621468 100644 (file)
@@ -270,6 +270,13 @@ class FSTestCase(unittest.TestCase):
                             os.path.join('ddd', 'f2'),
                             os.path.join('ddd', 'f3')]
 
+        # Test for a bug in 0.04 that did not like looking up
+        # dirs with a trailing slash on Win32.
+        d=fs.Dir('./')
+        assert d.path_ == '.' + os.sep, d.abspath_
+        d=fs.Dir('foo/')
+        assert d.path_ == 'foo' + os.sep, d.path_
+
         # Test for sub-classing of node building.
         global built_it