Commits

Amaury Forgeot d'Arc  committed 04e2b32

Test and fix for RopeString.find

  • Participants
  • Parent commits ffd032c

Comments (0)

Files changed (2)

File pypy/objspace/std/test/test_stringobject.py

         assert 'abcdefghiabc'.find('def', 4) == -1
         assert 'abcdef'.find('', 13) == -1
         assert 'abcdefg'.find('def', 5, None) == -1
+        assert 'abcdef'.find('d', 6, 0) == -1
+        assert 'abcdef'.find('d', 3, 3) == -1
+        raises(TypeError, 'abcdef'.find, 'd', 1.0)
 
     def test_index(self):
         from sys import maxint

File pypy/rlib/rope.py

     len2 = subnode.length()
     if stop > len1 or stop == -1:
         stop = len1
+    if stop - start < 0:
+        return -1
     if len2 == 1:
         return find_int(node, subnode.getint(0), start, stop)
     if len2 == 0:
-        if (stop - start) < 0:
-            return -1
         return start
     if len2 > stop - start:
         return -1