File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -651,11 +651,13 @@ PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force);
651651 ((PyObject*)(op))->ob_refcnt++)
652652
653653#define Py_DECREF (op ) \
654- if (_Py_DEC_REFTOTAL _Py_REF_DEBUG_COMMA \
655- --((PyObject*)(op))->ob_refcnt != 0) \
656- _Py_CHECK_REFCNT(op) \
657- else \
658- _Py_Dealloc((PyObject *)(op))
654+ do { \
655+ if (_Py_DEC_REFTOTAL _Py_REF_DEBUG_COMMA \
656+ --((PyObject*)(op))->ob_refcnt != 0) \
657+ _Py_CHECK_REFCNT(op) \
658+ else \
659+ _Py_Dealloc((PyObject *)(op)); \
660+ } while (0)
659661
660662/* Safely decref `op` and set `op` to NULL, especially useful in tp_clear
661663 * and tp_dealloc implementatons.
@@ -701,8 +703,8 @@ PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force);
701703 } while (0)
702704
703705/* Macros to use in case the object pointer may be NULL: */
704- #define Py_XINCREF (op ) if ((op) == NULL) ; else Py_INCREF(op)
705- #define Py_XDECREF (op ) if ((op) == NULL) ; else Py_DECREF(op)
706+ #define Py_XINCREF (op ) do { if ((op) == NULL) ; else Py_INCREF(op); } while (0 )
707+ #define Py_XDECREF (op ) do { if ((op) == NULL) ; else Py_DECREF(op); } while (0 )
706708
707709/*
708710These are provided as conveniences to Python runtime embedders, so that
Original file line number Diff line number Diff line change @@ -12,6 +12,9 @@ What's New in Python 3.1 beta 1?
1212Core and Builtins
1313-----------------
1414
15+ - Issue #1113244: Py_XINCREF, Py_DECREF, Py_XDECREF: Add `do { ... } while (0)'
16+ to avoid compiler warnings.
17+
1518Library
1619-------
1720
@@ -78,8 +81,6 @@ Core and Builtins
7881- Issue #3845: In PyRun_SimpleFileExFlags avoid invalid memory access with
7982 short file names.
8083
81- - Py_DECREF: Add `do { ... } while (0)' to avoid compiler warnings.
82-
8384Library
8485-------
8586
Original file line number Diff line number Diff line change @@ -693,13 +693,13 @@ on_completion_display_matches_hook(char **matches,
693693 r = PyObject_CallFunction (completion_display_matches_hook ,
694694 "sOi" , matches [0 ], m , max_length );
695695
696- Py_DECREF (m ), m = NULL ;
696+ Py_DECREF (m ); m = NULL ;
697697
698698 if (r == NULL ||
699699 (r != Py_None && PyLong_AsLong (r ) == -1 && PyErr_Occurred ())) {
700700 goto error ;
701701 }
702- Py_XDECREF (r ), r = NULL ;
702+ Py_XDECREF (r ); r = NULL ;
703703
704704 if (0 ) {
705705 error :
You can’t perform that action at this time.
0 commit comments