[Python-Dev] RE: [Python-checkins] python/dist/src/Objects listobject.c, 2.218, 2.219 (original) (raw)

Armin Rigo arigo at tunes.org
Tue Aug 3 11:12:33 CEST 2004


Hello Raymond,

On Mon, Aug 02, 2004 at 01:11:49PM -0400, Raymond Hettinger wrote:

> * complain about the unused name. > */ > ! return status, v; > } > > --- 863,867 ---- > * complain about the unused name. > */ > ! return status++, v;

Does anyone else see this as perverse?

Yes! And obfuscated definitely. A general solution to this problem would be helpful... well in this case I can think about a specific solution:

assert(!PyErr_Occurred());

Patch below.

Armin

*** listobject.c 3 Aug 2004 04:53:29 -0000 2.219 --- listobject.c 3 Aug 2004 09:15:45 -0000


*** 829,835 **** { int i = -1; PyObject *v, *arg = NULL;

--- 829,834 ----


*** 852,868 **** } v = self->ob_item[i]; if (i == self->ob_size - 1) { ! status = list_resize(self, self->ob_size - 1); ! assert(status >= 0); return v; /* and v now owns the reference the list had */ } Py_INCREF(v); ! status = list_ass_slice(self, i, i+1, (PyObject )NULL); ! assert(status >= 0); ! / Use status, so that in a release build compilers don't ! * complain about the unused name. ! */ ! return status++, v; }

/* Reverse a slice of a list in place, from lo up to (exclusive) hi. / --- 851,863 ---- } v = self->ob_item[i]; if (i == self->ob_size - 1) { ! list_resize(self, self->ob_size - 1); return v; / and v now owns the reference the list had */ } Py_INCREF(v); ! list_ass_slice(self, i, i+1, (PyObject *)NULL); ! assert(!PyErr_Occurred()); ! return v; }

/* Reverse a slice of a list in place, from lo up to (exclusive) hi. */



More information about the Python-Dev mailing list