Py_XDECREF/Py_DECREF evaluating its argument more than once

Chris Angelico rosuav at gmail.com
Thu May 5 20:59:59 EDT 2011


Clarification: This IS stated in the source - in object.h are the
following sage words:

---
*** WARNING*** The Py_DECREF macro must have a side-effect-free argument
since it may evaluate its argument multiple times.  (The alternative
would be to mace it a proper function or assign it to a global temporary
variable first, both of which are slower; and in a multi-threaded
environment the global variable trick is not safe.)
---

(I assume that should be "make" not "mace", unless the implication is
that turning a macro into a function involves pounding it into
submission...)

Since inline functions are a part of C99 as well as C++, would it be
possible to have configure.sh detect its availability and optionally
use that instead of preprocessor macros, or would this run the risk of
encouraging trickily unportable code?

Chris Angelico



More information about the Python-list mailing list