mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Added checks to prevent PyUnicode_Count() from dumping core
in case the parameters are out of bounds and fixes error handling for .count(), .startswith() and .endswith() for the case of mixed string/Unicode objects. This patch adds Python style index semantics to PyUnicode_Count() indices (including the special handling of negative indices). The patch is an extended version of patch #103249 submitted by Michael Hudson (mwh) on SF. It also includes new test cases.
This commit is contained in:
parent
1c5aa6901f
commit
3a645e4dd4
4 changed files with 56 additions and 19 deletions
|
@ -53,6 +53,10 @@ def run_method_tests(test):
|
|||
|
||||
test('capitalize', ' hello ', ' hello ')
|
||||
test('capitalize', 'hello ', 'Hello ')
|
||||
|
||||
test('count', 'aaa', 3, 'a')
|
||||
test('count', 'aaa', 0, 'b')
|
||||
|
||||
test('find', 'abcdefghiabc', 0, 'abc')
|
||||
test('find', 'abcdefghiabc', 9, 'abc', 1)
|
||||
test('find', 'abcdefghiabc', -1, 'def', 4)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue