[Patches] fix string methods implementing slice-like arguments (was:issues with int/long on 64bit platforms - eg stringobject (PR#306))

Guido van Rossum guido@python.org
Mon, 08 May 2000 10:09:35 -0400


> 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 indeces. 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.

Thanks, Trent!

Did you look into unicodeobject.c?  It has similar methods with
similar weaknesses!

--Guido van Rossum (home page: http://www.python.org/~guido/)