[Python-Dev] Re: RE: [Python-checkins] python/dist/src/Objectstypeobject.c, 2.244, 2.245

Terry Reedy tjreedy at udel.edu
Thu Oct 9 12:58:40 EDT 2003


> > Guido van Rossum <guido at python.org>:
> >
> > > Maybe PyBool_FromLong() itself could make this unneeded by
adding
> > > something like
> > >
> > >     if (ok < 0 && PyErr_Occurred())
> > >         return NULL;
> > >
> > > to its start?
>
> [Greg Ewing]
> > I can see someone coming along later and adding some code
> > in between whatever returned the result and the PyBool_FromLong
> > call, not realising that doing so would upset the error
> > checking.

My C is a bit rusty (from being swallowed by a Python)...
but in the particular snippet being discussed, it seems that
incorporating the error check in PyBool... would eliminate the need
for the temporary res variable, so that all can be written as

PyBool_FromLong( (*func)(self, value)); /* is (long) cast needed? */

leaving very little 'in between' space in which to insert upsetting
code.

I have no idea how well this generalizes to other prospective uses.

Terry J. Reedy







More information about the Python-Dev mailing list