> > 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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4