[Python-Dev] PySlice_GetIndicesEx annd stable ABI: bikeshedding (original) (raw)
Serhiy Storchaka storchaka at gmail.com
Thu Dec 22 05:34:39 EST 2016
- Previous message (by thread): [Python-Dev] PySlice_GetIndicesEx annd stable ABI: bikeshedding
- Next message (by thread): [Python-Dev] Python related issue
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 22.12.16 12:16, Armin Rigo wrote:
On 21 December 2016 at 15:51, Serhiy Storchaka <storchaka at gmail.com> wrote:
The code
if (PySliceGetIndicesEx(item, length, &start, &stop, &step, &slicelength) < 0) return -1; should be replaced with if (foo(item, &start, &stop, &step) < 0) return -1; slicelength = bar(&start, &stop, step, length); As far as I can tell, as written, this change would not fix anything. Shouldn't it be along the following lines instead? if (foo(item, &start, &stop, &step) < 0) return -1; length = PyListGETSIZE(mylist); /* <= after foo() */ slicelength = bar(&start, &stop, &step, length);
Yes, the point is that length is not a constant, but a result of an expression and should be evaluated after calling foo().
step is not changed by bar() and can be passed by value to it.
- Previous message (by thread): [Python-Dev] PySlice_GetIndicesEx annd stable ABI: bikeshedding
- Next message (by thread): [Python-Dev] Python related issue
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]