slicing of structseq objects fails

Python-devvers, Russel Owen reported the following bug, and it turns out to be a general bug, not a MacPython one: slicing the structseq-style tuples returned by time.gmtime() returns a sequence with NULLs in it. Shortly afterwards Python crashes on my SGI. Any takers? Recently, Russell E Owen <owen@astro.washington.edu> said:

jack wrote:
also note:
in structseq_slice, for(i = low; i < high; ++i) { PyObject *v = obj->ob_item[i]; Py_INCREF(v); PyTuple_SET_ITEM(np, i, v); } should be: for(i = low; i < high; ++i) { PyObject *v = obj->ob_item[i]; Py_INCREF(v); PyTuple_SET_ITEM(np, i-low, v); } </F>

tim wrote:
Bingo. First Jack reports a bug here, then /F goes to the trouble of copying in before-and-after code instead of just checking in the fix.
I didn't have enough time to rebuild and validate the patch, and I didn't want to risk checking anything in that didn't compile ;-) </F>

jack wrote:
also note:
in structseq_slice, for(i = low; i < high; ++i) { PyObject *v = obj->ob_item[i]; Py_INCREF(v); PyTuple_SET_ITEM(np, i, v); } should be: for(i = low; i < high; ++i) { PyObject *v = obj->ob_item[i]; Py_INCREF(v); PyTuple_SET_ITEM(np, i-low, v); } </F>

tim wrote:
Bingo. First Jack reports a bug here, then /F goes to the trouble of copying in before-and-after code instead of just checking in the fix.
I didn't have enough time to rebuild and validate the patch, and I didn't want to risk checking anything in that didn't compile ;-) </F>
participants (3)
-
Fredrik Lundh
-
Jack Jansen
-
Tim Peters