diff options
| author | Thomas Wouters <thomas@python.org> | 2006-04-15 17:28:34 +0000 |
|---|---|---|
| committer | Thomas Wouters <thomas@python.org> | 2006-04-15 17:28:34 +0000 |
| commit | edf17d8798e65c10c970ef86f7374f6c1b51027a (patch) | |
| tree | 743ac540a38640d5b550c9b9636ca8ee5f86a0dd /Objects | |
| parent | ed8f78312654d74329892252d720d78765495c38 (diff) | |
| download | cpython-git-edf17d8798e65c10c970ef86f7374f6c1b51027a.tar.gz | |
Use Py_CLEAR instead of in-place DECREF/XDECREF or custom macros, for
tp_clear methods.
Diffstat (limited to 'Objects')
| -rw-r--r-- | Objects/cellobject.c | 3 | ||||
| -rw-r--r-- | Objects/funcobject.c | 4 | ||||
| -rw-r--r-- | Objects/typeobject.c | 13 |
3 files changed, 4 insertions, 16 deletions
diff --git a/Objects/cellobject.c b/Objects/cellobject.c index 97044032fc..e617e5e5f3 100644 --- a/Objects/cellobject.c +++ b/Objects/cellobject.c @@ -81,8 +81,7 @@ cell_traverse(PyCellObject *op, visitproc visit, void *arg) static int cell_clear(PyCellObject *op) { - Py_XDECREF(op->ob_ref); - op->ob_ref = NULL; + Py_CLEAR(op->ob_ref); return 0; } diff --git a/Objects/funcobject.c b/Objects/funcobject.c index 00ae2ebe8a..b86319cad8 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -655,9 +655,7 @@ cm_traverse(classmethod *cm, visitproc visit, void *arg) static int cm_clear(classmethod *cm) { - Py_XDECREF(cm->cm_callable); - cm->cm_callable = NULL; - + Py_CLEAR(cm->cm_callable); return 0; } diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 1c74322d87..a0af2c9b42 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -559,8 +559,8 @@ clear_slots(PyTypeObject *type, PyObject *self) char *addr = (char *)self + mp->offset; PyObject *obj = *(PyObject **)addr; if (obj != NULL) { - Py_DECREF(obj); *(PyObject **)addr = NULL; + Py_DECREF(obj); } } } @@ -2236,13 +2236,6 @@ type_clear(PyTypeObject *type) for heaptypes. */ assert(type->tp_flags & Py_TPFLAGS_HEAPTYPE); -#define CLEAR(SLOT) \ - if (SLOT) { \ - tmp = (PyObject *)(SLOT); \ - SLOT = NULL; \ - Py_DECREF(tmp); \ - } - /* The only field we need to clear is tp_mro, which is part of a hard cycle (its first element is the class itself) that won't be broken otherwise (it's a tuple and tuples don't have a @@ -2268,9 +2261,7 @@ type_clear(PyTypeObject *type) A tuple of strings can't be part of a cycle. */ - CLEAR(type->tp_mro); - -#undef CLEAR + Py_CLEAR(type->tp_mro); return 0; } |
