New issue 2599: Py_XINCREF/Py_XDECREF use argument twice
https://bitbucket.org/pypy/pypy/issues/2599/py_xincref-py_xdecref-use-argument-twice

Marian Beermann:

This isn't documented, but in CPython these are implemented to never use the 
macro's argument twice:

```
#define Py_XDECREF(op)                                \
    do {                                              \
        PyObject *_py_xdecref_tmp = (PyObject *)(op); \
        if (_py_xdecref_tmp != NULL)                  \
            Py_DECREF(_py_xdecref_tmp);               \
    } while (0)
```

PyPy does:

```
#define Py_XDECREF(op) do { if ((op) == NULL) ; else Py_DECREF(op); } while (0)
```

I didn't notice this in my code, and it's bad style (and I'll fix it in my code 
;), but Google suggests that writing `Py_XDECREF(PyObject_CallMethod(...` is 
somewhat common.


_______________________________________________
pypy-issue mailing list
pypy-issue@python.org
https://mail.python.org/mailman/listinfo/pypy-issue

Reply via email to