Bug in Python/C API?

Rainer Deyke root at rainerdeyke.com
Wed Sep 13 07:05:45 CEST 2000


"Paul Duffin" <pduffin at hursley.ibm.com> wrote in message
news:39BDE70F.12AA725C at hursley.ibm.com...
> Rainer Deyke wrote:
> > This sort of problem could be prevented if Py_XDECREF was defined like
this:
> >
> > #define Py_XDECREF(A) if (tmp = (A)) Py_DECREF(A)
> >
> > where tmp is a global PyObject *.
> >
>
> You probably mean
> #define Py_XDECREF(A) if (tmp = (A)) Py_DECREF(tmp)

Yes. :-)

> a global is not a good idea because if it is used by multiple threads
> then you will have severe problems.
>
> #define Py_XDECREF(A) {PyObject *tmp = (A); if (tmp) Py_DECREF(tmp);}

Better still.  I don't think in terms of threads, since I never use them.


--
Rainer Deyke (root at rainerdeyke.com)
Shareware computer games           -           http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor





More information about the Python-list mailing list