mirror of
https://github.com/python/cpython.git
synced 2025-08-22 01:35:16 +00:00
gh-95324: Emit a warning if an object doesn't call PyObject_GC_UnTrack during deallocation in debug mode (#95325)
This commit is contained in:
parent
2833f3798d
commit
f40bc7fa49
8 changed files with 18 additions and 2 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue