STINNER Victor <vstin...@redhat.com> added the comment:
I'm not sure if I should include an unit test. WIP patch for that: diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 350ef77163..9c0d0cf41a 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -4718,6 +4718,18 @@ negative_refcount(PyObject *self, PyObject *Py_UNUSED(args)) #endif +static PyObject * +corrupted_object(PyObject *self, PyObject *Py_UNUSED(args)) +{ + PyObject *obj = PyList_New(0); + if (obj == NULL) { + return NULL; + } + obj->ob_type = NULL; + return obj; +} + + static PyMethodDef TestMethods[] = { {"raise_exception", raise_exception, METH_VARARGS}, {"raise_memoryerror", raise_memoryerror, METH_NOARGS}, @@ -4948,6 +4960,7 @@ static PyMethodDef TestMethods[] = { #ifdef Py_REF_DEBUG {"negative_refcount", negative_refcount, METH_NOARGS}, #endif + {"corrupted_object", corrupted_object, METH_NOARGS}, {NULL, NULL} /* sentinel */ }; Tested manually using this script: --- import gc, _testcapi, sys gc.enable_object_debugger(1) x = _testcapi.corrupted_object() y = [] y = None # Debugger should trigger here x = None --- ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue36389> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com