diff -r 406c6fd7e753 Include/object.h --- a/Include/object.h Sun Mar 17 21:53:48 2013 -0400 +++ b/Include/object.h Sun Mar 17 23:32:41 2013 -0700 @@ -809,6 +809,8 @@ * Python integers aren't currently weakly referencable. Best practice is * to use Py_CLEAR() even if you can't think of a reason for why you need to. */ + + #define Py_CLEAR(op) \ do { \ if (op) { \ @@ -819,9 +821,29 @@ } while (0) /* Macros to use in case the object pointer may be NULL: */ +#ifdef OLD_17206 + #define Py_XINCREF(op) do { if ((op) == NULL) ; else Py_INCREF(op); } while (0) #define Py_XDECREF(op) do { if ((op) == NULL) ; else Py_DECREF(op); } while (0) +#else + +#define Py_XINCREF(op) \ + do { \ + PyObject* _py_tmp=(PyObject*)(op); \ + if (_py_tmp != NULL) \ + Py_INCREF(_py_tmp); \ + } while (0) + +#define Py_XDECREF(op) \ + do { \ + PyObject* _py_tmp=(PyObject*)(op); \ + if (_py_tmp != NULL) \ + Py_DECREF(_py_tmp); \ + } while (0) + +#endif + /* These are provided as conveniences to Python runtime embedders, so that they can have object code that is not dependent on Python compilation flags. diff -r 406c6fd7e753 Misc/ACKS --- a/Misc/ACKS Sun Mar 17 21:53:48 2013 -0400 +++ b/Misc/ACKS Sun Mar 17 23:32:41 2013 -0700 @@ -960,6 +960,7 @@ Remi Pointel Ariel Poliak Guilherme Polo +Illia Polosukhin Michael Pomraning Iustin Pop Claudiu Popa diff -r 406c6fd7e753 Misc/NEWS --- a/Misc/NEWS Sun Mar 17 21:53:48 2013 -0400 +++ b/Misc/NEWS Sun Mar 17 23:32:41 2013 -0700 @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #17206: Py_XDECREF() and Py_XINCREF() now expands their arguments once + instead of multiple times. Patch written by Illia Polosukhin. + - Issue #17434: Properly raise a SyntaxError when a string occurs between future imports.