Index: Lib/test/string_tests.py =================================================================== --- Lib/test/string_tests.py (revision 76951) +++ Lib/test/string_tests.py (working copy) @@ -185,6 +185,9 @@ self.checkequal(-1, '', 'find', 'xx', 1, 1) self.checkequal(-1, '', 'find', 'xx', sys.maxint, 0) + # issue 7458 + self.checkequal(-1, 'ab', 'find', 'xxx', sys.maxsize + 1, 0) + # For a variety of combinations, # verify that str.find() matches __contains__ # and that the found substring is really at that location @@ -230,6 +233,34 @@ self.checkraises(TypeError, 'hello', 'rfind') self.checkraises(TypeError, 'hello', 'rfind', 42) + # issue 7458 + self.checkequal(-1, 'ab', 'rfind', 'xxx', sys.maxsize + 1, 0) + + # For a variety of combinations, + # verify that str.rfind() matches __contains__ + # and that the found substring is really at that location + charset = ['', 'a', 'b', 'c'] + digits = 5 + base = len(charset) + teststrings = set() + for i in xrange(base ** digits): + entry = [] + for j in xrange(digits): + i, m = divmod(i, base) + entry.append(charset[m]) + teststrings.add(''.join(entry)) + teststrings = list(teststrings) + for i in teststrings: + i = self.fixtype(i) + for j in teststrings: + loc = i.rfind(j) + r1 = (loc != -1) + r2 = j in i + if r1 != r2: + self.assertEqual(r1, r2) + if loc != -1: + self.assertEqual(i[loc:loc+len(j)], j) + def test_index(self): self.checkequal(0, 'abcdefghiabc', 'index', '') self.checkequal(3, 'abcdefghiabc', 'index', 'def') @@ -686,8 +717,10 @@ EQ("bobobXbobob", "bobobobXbobobob", "replace", "bobob", "bob") EQ("BOBOBOB", "BOBOBOB", "replace", "bob", "bobby") - ba = buffer('a') - bb = buffer('b') + # Silence Py3k warning + with test_support.check_warnings(): + ba = buffer('a') + bb = buffer('b') EQ("bbc", "abc", "replace", ba, bb) EQ("aac", "abc", "replace", bb, ba) Index: Lib/test/test_unicode.py =================================================================== --- Lib/test/test_unicode.py (revision 76951) +++ Lib/test/test_unicode.py (working copy) @@ -499,9 +499,12 @@ ) if not sys.platform.startswith('java'): + # Silence Py3k warning + with test_support.check_warnings(): + buf = buffer('character buffers are decoded to unicode') self.assertEqual( unicode( - buffer('character buffers are decoded to unicode'), + buf, 'utf-8', 'strict' ),