From: neonene <53406459+neonene@users.noreply.github.com> Date: Mon, 8 Jan 2024 16:34:51 +0000 (+0900) Subject: gh-113787: Fix refleaks in test_capi (gh-113816) X-Git-Tag: v3.13.0a3~152 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ace4d7ff9a247cbe7350719b996a1c7d88a57813;p=thirdparty%2FPython%2Fcpython.git gh-113787: Fix refleaks in test_capi (gh-113816) Fix refleaks and a typo. --- diff --git a/Modules/_testcapi/vectorcall_limited.c b/Modules/_testcapi/vectorcall_limited.c index d7b8d33b7f71..d7070d37bb9e 100644 --- a/Modules/_testcapi/vectorcall_limited.c +++ b/Modules/_testcapi/vectorcall_limited.c @@ -195,6 +195,6 @@ _PyTestCapi_Init_VectorcallLimited(PyObject *m) { if (PyModule_AddType(m, (PyTypeObject *)LimitedVectorCallClass) < 0) { return -1; } - + Py_DECREF(LimitedVectorCallClass); return 0; } diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 6762c611fb12..398570ff8e05 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -49,7 +49,7 @@ get_testcapi_state(PyObject *module) static PyObject * get_testerror(PyObject *self) { - testcapistate_t *state = get_testcapi_state((PyObject *)Py_TYPE(self)); + testcapistate_t *state = get_testcapi_state(self); return state->error; } @@ -3947,7 +3947,6 @@ PyInit__testcapi(void) testcapistate_t *state = get_testcapi_state(m); state->error = PyErr_NewException("_testcapi.error", NULL, NULL); - Py_INCREF(state->error); PyModule_AddObject(m, "error", state->error); if (PyType_Ready(&ContainerNoGC_type) < 0) {