[Numpy-svn] r4246 - branches/numpy.scons/numpy/distutils/scons

numpy-svn@scip... numpy-svn@scip...
Thu Oct 18 19:54:55 CDT 2007


Author: cdavid
Date: 2007-10-18 19:54:51 -0500 (Thu, 18 Oct 2007)
New Revision: 4246

Modified:
   branches/numpy.scons/numpy/distutils/scons/utils.py
Log:
Bug in rsplit replacement when no sep in string fixed

Modified: branches/numpy.scons/numpy/distutils/scons/utils.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/utils.py	2007-10-19 00:09:02 UTC (rev 4245)
+++ branches/numpy.scons/numpy/distutils/scons/utils.py	2007-10-19 00:54:51 UTC (rev 4246)
@@ -52,10 +52,10 @@
 def _rsplit(s, sep, max):
     """Equivalent of rsplit, but works on 2.3."""
     l = s.split(sep)
-    if max < 0:
+    if len(l) < 2 or max == 0:
+        return [s]
+    elif max < 0:
         return l[-len(l):]
-    elif max == 0:
-        return [s]
     else:
         st = sep.join(l[0:-max])
         return [st] + l[-max:]
@@ -84,3 +84,7 @@
     assert a1.rsplit('.', 0) == _rsplit(a1, '.', 0)
 
     assert a1.rsplit('.', 2) == _rsplit(a1, '.', 2)
+
+    a2 = 'floupi'
+    assert a2.rsplit('.') ==  _rsplit(a2, '.', -1)
+    assert a2.rsplit('.', 1) == _rsplit(a2, '.', 1)



More information about the Numpy-svn mailing list