This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author stutzbach
Recipients stutzbach
Date 2008-07-03.17:54:07
SpamBayes Score 0.0
Marked as misclassified No
Message-id <1215107649.04.0.488182300536.issue3274@psf.upfronthosting.co.za>
In-reply-to
Content
I'm writing a C extension module and discovered that Py_CLEAR() causes a
crash if the programmer happened to name their variable "tmp".  The
Py_CLEAR() macro internally uses the name "tmp" in a new scope, hiding
the callers "tmp", and calling Py_DECREF() on an essentially random bit
of memory.

I suggest changing Py_CLEAR() to use something a little less common than
"tmp".  Perhaps "_py_tmp".

For easy reference, here's how Py_CLEAR() is defined now:

#define Py_CLEAR(op)				\
        do {                            	\
                if (op) {			\
                        PyObject *tmp = (PyObject *)(op);	\
                        (op) = NULL;		\
                        Py_DECREF(tmp);		\
                }				\
        } while (0)
History
Date User Action Args
2008-07-08 09:09:23georg.brandlsetspambayes_score: 0.00544041 -> 0.0
2008-07-03 17:54:09stutzbachsetspambayes_score: 0.00544041 -> 0.00544041
recipients: + stutzbach
2008-07-03 17:54:09stutzbachsetspambayes_score: 0.00544041 -> 0.00544041
messageid: <1215107649.04.0.488182300536.issue3274@psf.upfronthosting.co.za>
2008-07-03 17:54:08stutzbachlinkissue3274 messages
2008-07-03 17:54:07stutzbachcreate