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

Sjoerd Mullender sjoerd at acm.org
Tue Aug 3 11:48:24 CEST 2004


Armin Rigo wrote:

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:

This is indeed perverted. Another option is to add a statement (void) status; somewhere to the function and to remove the status++ from the return. This seems to shut up all compilers I've dealt with.

assert(!PyErrOccurred());

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; - int status; if (!PyArgUnpackTuple(args, "pop", 0, 1, &arg)) return NULL; --- 829,834 ---- *************** *** 852,868 **** } v = self->obitem[i]; if (i == self->obsize - 1) { ! status = listresize(self, self->obsize - 1); ! assert(status >= 0); return v; /* and v now owns the reference the list had */ } PyINCREF(v); ! status = listassslice(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->obitem[i]; if (i == self->obsize - 1) { ! listresize(self, self->obsize - 1); return v; /* and v now owns the reference the list had */ } PyINCREF(v); ! listassslice(self, i, i+1, (PyObject *)NULL); ! assert(!PyErrOccurred()); ! return v; } /* Reverse a slice of a list in place, from lo up to (exclusive) hi. */


Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/sjoerd%40acm.org

-- Sjoerd Mullender <sjoerd at acm.org> -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 374 bytes Desc: OpenPGP digital signature Url : http://mail.python.org/pipermail/python-dev/attachments/20040803/abc2c638/signature.pgp



More information about the Python-Dev mailing list