Commit c682140
committed
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?]1 parent 20c6add commit c682140
1 file changed
Lines changed: 9 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
822 | 822 | | |
823 | 823 | | |
824 | 824 | | |
825 | | - | |
826 | | - | |
| 825 | + | |
| 826 | + | |
827 | 827 | | |
828 | 828 | | |
829 | 829 | | |
| |||
1194 | 1194 | | |
1195 | 1195 | | |
1196 | 1196 | | |
1197 | | - | |
| 1197 | + | |
| 1198 | + | |
1198 | 1199 | | |
| 1200 | + | |
1199 | 1201 | | |
1200 | 1202 | | |
1201 | 1203 | | |
| |||
1617 | 1619 | | |
1618 | 1620 | | |
1619 | 1621 | | |
1620 | | - | |
| 1622 | + | |
| 1623 | + | |
1621 | 1624 | | |
1622 | 1625 | | |
1623 | 1626 | | |
| |||
1671 | 1674 | | |
1672 | 1675 | | |
1673 | 1676 | | |
1674 | | - | |
| 1677 | + | |
| 1678 | + | |
1675 | 1679 | | |
1676 | 1680 | | |
1677 | 1681 | | |
| |||
0 commit comments