mirror of https://github.com/python/cpython
gh-115058: Add ``reset_rare_event_counters`` function in `_testinternalcapi` (GH-115128)
This commit is contained in:
parent
95ebd45613
commit
93ac78ac3e
|
@ -7,6 +7,9 @@ _testinternalcapi = import_helper.import_module("_testinternalcapi")
|
|||
|
||||
|
||||
class TestRareEventCounters(unittest.TestCase):
|
||||
def setUp(self):
|
||||
_testinternalcapi.reset_rare_event_counters()
|
||||
|
||||
def test_set_class(self):
|
||||
class A:
|
||||
pass
|
||||
|
|
|
@ -1650,6 +1650,20 @@ get_rare_event_counters(PyObject *self, PyObject *type)
|
|||
);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
reset_rare_event_counters(PyObject *self, PyObject *Py_UNUSED(type))
|
||||
{
|
||||
PyInterpreterState *interp = PyInterpreterState_Get();
|
||||
|
||||
interp->rare_events.set_class = 0;
|
||||
interp->rare_events.set_bases = 0;
|
||||
interp->rare_events.set_eval_frame_func = 0;
|
||||
interp->rare_events.builtin_dict = 0;
|
||||
interp->rare_events.func_modification = 0;
|
||||
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
|
||||
#ifdef Py_GIL_DISABLED
|
||||
static PyObject *
|
||||
|
@ -1727,6 +1741,7 @@ static PyMethodDef module_functions[] = {
|
|||
_TESTINTERNALCAPI_TEST_LONG_NUMBITS_METHODDEF
|
||||
{"get_type_module_name", get_type_module_name, METH_O},
|
||||
{"get_rare_event_counters", get_rare_event_counters, METH_NOARGS},
|
||||
{"reset_rare_event_counters", reset_rare_event_counters, METH_NOARGS},
|
||||
#ifdef Py_GIL_DISABLED
|
||||
{"py_thread_id", get_py_thread_id, METH_NOARGS},
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue