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

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(!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;
> -       int status;
>   
>         if (!PyArg_UnpackTuple(args, "pop", 0, 1, &arg))
>                 return 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. */
> _______________________________________________
> 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