]> granicus.if.org Git - python/commit
Trent Mick:
authorGuido van Rossum <guido@python.org>
Mon, 8 May 2000 14:08:05 +0000 (14:08 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 8 May 2000 14:08:05 +0000 (14:08 +0000)
commitc682140de7656db69b9d395c1a80f1b429ef0ae7
tree70d5257b81111a2ef6de94f5760cbe7925b7f6d3
parent20c6add7ff268340797cc8a038a79417e98a7a8c
Trent Mick:

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?]
Objects/stringobject.c