mirror of
https://github.com/python/cpython.git
synced 2025-11-03 11:23:31 +00:00
Fix the string methods that implement slice-like semantics with optional args (count, find, endswith, etc.) to properly handle indeces outside [INT_MIN, INT_MAX]. Previously the "i" formatter for PyArg_ParseTuple was used to get the indices. These could overflow. This patch changes the string methods to use the "O&" formatter with the slice_index() function from ceval.c which is used to do the same job for Python code slices (e.g. 'abcabcabc'[0:1000000000L]). slice_index() is renamed _PyEval_SliceIndex() and is now exported. As well, the return values for success/fail were changed to make slice_index directly usable as required by the "O&" formatter. [GvR: shouldn't a similar patch be applied to unicodeobject.c?] |
||
|---|---|---|
| .. | ||
| .cvsignore | ||
| abstract.c | ||
| bufferobject.c | ||
| classobject.c | ||
| cobject.c | ||
| complexobject.c | ||
| dictobject.c | ||
| fileobject.c | ||
| floatobject.c | ||
| frameobject.c | ||
| funcobject.c | ||
| intobject.c | ||
| listobject.c | ||
| longobject.c | ||
| Makefile.in | ||
| methodobject.c | ||
| moduleobject.c | ||
| object.c | ||
| rangeobject.c | ||
| sliceobject.c | ||
| stringobject.c | ||
| tupleobject.c | ||
| typeobject.c | ||
| unicodectype.c | ||
| unicodeobject.c | ||
| xxobject.c | ||