]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-113787: Fix refleaks in test_capi (gh-113816)
authorneonene <53406459+neonene@users.noreply.github.com>
Mon, 8 Jan 2024 16:34:51 +0000 (01:34 +0900)
committerGitHub <noreply@github.com>
Mon, 8 Jan 2024 16:34:51 +0000 (08:34 -0800)
Fix refleaks and a typo.

Modules/_testcapi/vectorcall_limited.c
Modules/_testcapimodule.c

index d7b8d33b7f716203190bc0a9974c5274ccd09615..d7070d37bb9e9bd047bf94e2dea12041167a02cd 100644 (file)
@@ -195,6 +195,6 @@ _PyTestCapi_Init_VectorcallLimited(PyObject *m) {
     if (PyModule_AddType(m, (PyTypeObject *)LimitedVectorCallClass) < 0) {
         return -1;
     }
-
+    Py_DECREF(LimitedVectorCallClass);
     return 0;
 }
index 6762c611fb12a20c337704d72c4ddd5889effaea..398570ff8e05c6f97f53d373014f62a07591799c 100644 (file)
@@ -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) {