[Python-Dev] Bad interaction of index and sequence repeat (original) (raw)
Armin Rigo arigo at tunes.org
Fri Jul 28 12:11:33 CEST 2006
- Previous message: [Python-Dev] Py2.5 release schedule
- Next message: [Python-Dev] Bad interaction of __index__ and sequence repeat
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
There is an oversight in the design of index() that only just surfaced :-( It is responsible for the following behavior, on a 32-bit machine with >= 2GB of RAM:
>>> s = 'x' * (2**100) # works!
>>> len(s)
2147483647
This is because PySequence_Repeat(v, w) works by applying w.index in order to call v->sq_repeat. However, index is defined to clip the result to fit in a Py_ssize_t. This means that the above problem exists with all sequences, not just strings, given enough RAM to create such sequences with 2147483647 items.
For reference, in 2.4 we correctly get an OverflowError.
Argh! What should be done about it?
A bientot,
Armin.
- Previous message: [Python-Dev] Py2.5 release schedule
- Next message: [Python-Dev] Bad interaction of __index__ and sequence repeat
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]