diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2022-07-27 15:03:38 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-27 15:03:38 (GMT) |
commit | f40bc7fa49f8d137f9b38f7a14569e9a9bdbed07 (patch) | |
tree | 01f24798d6ac958feac40337a0a877ba60a66b5f /Objects/exceptions.c | |
parent | 2833f3798dc3647e850b303a4d0fa00609a0ae9b (diff) | |
download | cpython-f40bc7fa49f8d137f9b38f7a14569e9a9bdbed07.zip cpython-f40bc7fa49f8d137f9b38f7a14569e9a9bdbed07.tar.gz cpython-f40bc7fa49f8d137f9b38f7a14569e9a9bdbed07.tar.bz2 |
gh-95324: Emit a warning if an object doesn't call PyObject_GC_UnTrack during deallocation in debug mode (#95325)
Diffstat (limited to 'Objects/exceptions.c')
-rw-r--r-- | Objects/exceptions.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c index e06a8f4..745b890 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -3214,6 +3214,7 @@ MemoryError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) self = state->memerrors_freelist; self->args = PyTuple_New(0); /* This shouldn't happen since the empty tuple is persistent */ + if (self->args == NULL) { return NULL; } @@ -3229,6 +3230,8 @@ MemoryError_new(PyTypeObject *type, PyObject *args, PyObject *kwds) static void MemoryError_dealloc(PyBaseExceptionObject *self) { + _PyObject_GC_UNTRACK(self); + BaseException_clear(self); /* If this is a subclass of MemoryError, we don't need to @@ -3238,8 +3241,6 @@ MemoryError_dealloc(PyBaseExceptionObject *self) return; } - _PyObject_GC_UNTRACK(self); - struct _Py_exc_state *state = get_exc_state(); if (state->memerrors_numfree >= MEMERRORS_SAVE) { Py_TYPE(self)->tp_free((PyObject *)self); |