diff -r 1ceb91974dc4 Include/boolobject.h --- a/Include/boolobject.h Sat Apr 30 01:30:57 2016 +0000 +++ b/Include/boolobject.h Fri Apr 29 21:31:44 2016 -0700 @@ -22,8 +22,8 @@ #define Py_True ((PyObject *) &_Py_TrueStruct) /* Macros for returning Py_True or Py_False, respectively */ -#define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True -#define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False +#define Py_RETURN_TRUE return Py_True +#define Py_RETURN_FALSE return Py_False /* Function to return a bool from a C long */ PyAPI_FUNC(PyObject *) PyBool_FromLong(long); diff -r 1ceb91974dc4 Include/object.h --- a/Include/object.h Sat Apr 30 01:30:57 2016 +0000 +++ b/Include/object.h Fri Apr 29 21:31:44 2016 -0700 @@ -774,19 +774,8 @@ #endif #endif /* !Py_TRACE_REFS */ -#define Py_INCREF(op) ( \ - _Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \ - ((PyObject *)(op))->ob_refcnt++) - -#define Py_DECREF(op) \ - do { \ - PyObject *_py_decref_tmp = (PyObject *)(op); \ - if (_Py_DEC_REFTOTAL _Py_REF_DEBUG_COMMA \ - --(_py_decref_tmp)->ob_refcnt != 0) \ - _Py_CHECK_REFCNT(_py_decref_tmp) \ - else \ - _Py_Dealloc(_py_decref_tmp); \ - } while (0) +#define Py_INCREF(op) +#define Py_DECREF(op) /* Safely decref `op` and set `op` to NULL, especially useful in tp_clear * and tp_dealloc implementations. @@ -867,18 +856,10 @@ */ #define Py_SETREF(op, op2) \ - do { \ - PyObject *_py_tmp = (PyObject *)(op); \ - (op) = (op2); \ - Py_DECREF(_py_tmp); \ - } while (0) + (op) = (op2) \ #define Py_XSETREF(op, op2) \ - do { \ - PyObject *_py_tmp = (PyObject *)(op); \ - (op) = (op2); \ - Py_XDECREF(_py_tmp); \ - } while (0) + (op) = (op2) \ #endif /* ifndef Py_LIMITED_API */ @@ -902,7 +883,7 @@ #define Py_None (&_Py_NoneStruct) /* Macro for returning Py_None from a function */ -#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None +#define Py_RETURN_NONE return Py_None /* Py_NotImplemented is a singleton used to signal that an operation is @@ -913,7 +894,7 @@ /* Macro for returning Py_NotImplemented from a function */ #define Py_RETURN_NOTIMPLEMENTED \ - return Py_INCREF(Py_NotImplemented), Py_NotImplemented + return Py_NotImplemented /* Rich comparison opcodes */ #define Py_LT 0 diff -r 1ceb91974dc4 Objects/object.c --- a/Objects/object.c Sat Apr 30 01:30:57 2016 +0000 +++ b/Objects/object.c Fri Apr 29 21:31:44 2016 -0700 @@ -1729,7 +1729,7 @@ _Py_NewReference(PyObject *op) { _Py_INC_REFTOTAL; - op->ob_refcnt = 1; + op->ob_refcnt = 2; _Py_AddToAllObjects(op, 1); _Py_INC_TPALLOCS(op); }