diff options
author | Thomas Wouters <thomas@python.org> | 2006-04-15 17:28:34 (GMT) |
---|---|---|
committer | Thomas Wouters <thomas@python.org> | 2006-04-15 17:28:34 (GMT) |
commit | edf17d8798e65c10c970ef86f7374f6c1b51027a (patch) | |
tree | 743ac540a38640d5b550c9b9636ca8ee5f86a0dd /Objects/typeobject.c | |
parent | ed8f78312654d74329892252d720d78765495c38 (diff) | |
download | cpython-edf17d8798e65c10c970ef86f7374f6c1b51027a.zip cpython-edf17d8798e65c10c970ef86f7374f6c1b51027a.tar.gz cpython-edf17d8798e65c10c970ef86f7374f6c1b51027a.tar.bz2 |
Use Py_CLEAR instead of in-place DECREF/XDECREF or custom macros, for
tp_clear methods.
Diffstat (limited to 'Objects/typeobject.c')
-rw-r--r-- | Objects/typeobject.c | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 1c74322..a0af2c9 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; } |