diff -r 2dd1b056d663 Lib/test/string_tests.py --- a/Lib/test/string_tests.py Wed Aug 01 14:53:22 2012 +0200 +++ b/Lib/test/string_tests.py Thu Aug 02 14:45:59 2012 +0200 @@ -262,6 +262,9 @@ class BaseTest(unittest.TestCase): # issue 7458 self.checkequal(-1, 'ab', 'rfind', 'xxx', sys.maxsize + 1, 0) + # issue #15534 + self.checkequal(0, '<......\u043c...', "rfind", "<") + def test_index(self): self.checkequal(0, 'abcdefghiabc', 'index', '') self.checkequal(3, 'abcdefghiabc', 'index', 'def') @@ -597,6 +600,8 @@ class BaseTest(unittest.TestCase): EQ("ReyKKjavik", "Reykjavik", "replace", "k", "KK", 1) EQ("Reykjavik", "Reykjavik", "replace", "k", "KK", 0) EQ("A----B----C----", "A.B.C.", "replace", ".", "----") + # issue #15534 + EQ('...\u043c......<', '...\u043c......<', "replace", "<", "<") EQ("Reykjavik", "Reykjavik", "replace", "q", "KK") @@ -1316,6 +1321,9 @@ class MixinStrUnicodeUserStringTest: self.assertRaisesRegex(TypeError, r'^endswith\(', s.endswith, x, None, None, None) + # issue #15534 + self.checkequal(10, "...\u043c......<", "find", "<") + class MixinStrUnicodeTest: # Additional tests that only work with str and unicode. diff -r 2dd1b056d663 Objects/stringlib/fastsearch.h --- a/Objects/stringlib/fastsearch.h Wed Aug 01 14:53:22 2012 +0200 +++ b/Objects/stringlib/fastsearch.h Thu Aug 02 14:45:59 2012 +0200 @@ -48,16 +48,16 @@ STRINGLIB(fastsearch_memchr_1char)(const } while (0) if (mode == FAST_SEARCH) { - const STRINGLIB_CHAR *_s = s; + const STRINGLIB_CHAR *ptr = s; const STRINGLIB_CHAR *e = s + n; - while (_s < e) { - DO_MEMCHR(memchr, _s, needle, e - _s); + while (ptr < e) { + DO_MEMCHR(memchr, ptr, needle, e - ptr); if (found == NULL) return -1; if (sizeof(STRINGLIB_CHAR) == 1 || *found == ch) - return (found - _s); + return (found - s); /* False positive */ - _s = found + 1; + ptr = found + 1; } return -1; }