Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Checkins

cpython: Close #15534: Fix a typo in the fast search function of the string library ( s

 

 

Python checkins RSS feed   Index | Next | Previous | View Threaded


python-checkins at python

Aug 2, 2012, 2:09 PM

Post #1 of 1 (39 views)
Permalink
cpython: Close #15534: Fix a typo in the fast search function of the string library ( s

http://hg.python.org/cpython/rev/0e95b61af859
changeset: 78386:0e95b61af859
user: Victor Stinner <victor.stinner [at] gmail>
date: Thu Aug 02 23:05:01 2012 +0200
summary:
Close #15534: Fix a typo in the fast search function of the string library (_s => s)

Replace _s with ptr to avoid future confusion. Add also non regression tests.

files:
Lib/test/string_tests.py | 8 ++++++++
Misc/NEWS | 4 +++-
Objects/stringlib/fastsearch.h | 10 +++++-----
3 files changed, 16 insertions(+), 6 deletions(-)


diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py
--- a/Lib/test/string_tests.py
+++ b/Lib/test/string_tests.py
@@ -262,6 +262,9 @@
# 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 @@
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......&lt;', '...\u043c......<', "replace", "<", "&lt;")

EQ("Reykjavik", "Reykjavik", "replace", "q", "KK")

@@ -1316,6 +1321,9 @@
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 --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,8 @@
Core and Builtins
-----------------

+- Issue #15534: Fix the fast-search function for non-ASCII Unicode strings.
+
- Issue #15508: Fix the docstring for __import__ to have the proper default
value of 0 for 'level' and to not mention negative levels since they are
not supported.
@@ -83,7 +85,7 @@

- Issue #15499: Launching a webbrowser in Unix used to sleep for a few
seconds. Original patch by Anton Barkovsky.
-
+
- Issue #15463: the faulthandler module truncates strings to 500 characters,
instead of 100, to be able to display long file paths

diff --git a/Objects/stringlib/fastsearch.h b/Objects/stringlib/fastsearch.h
--- a/Objects/stringlib/fastsearch.h
+++ b/Objects/stringlib/fastsearch.h
@@ -48,16 +48,16 @@
} 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;
}

--
Repository URL: http://hg.python.org/cpython

Python checkins RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.