Skip to content

Commit

Permalink
bpo-36854: Fix reference counter in PyInit__testcapi() (GH-17338)
Browse files Browse the repository at this point in the history
Increment properly Py_True/Py_False reference counter for
_testcapi.WITH_PYMALLOC variable.
  • Loading branch information
vstinner authored Nov 22, 2019
1 parent 107ed88 commit 84c36c1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Modules/_testcapimodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -6283,11 +6283,14 @@ PyInit__testcapi(void)
PyModule_AddObject(m, "instancemethod", (PyObject *)&PyInstanceMethod_Type);

PyModule_AddIntConstant(m, "the_number_three", 3);
PyObject *v;
#ifdef WITH_PYMALLOC
PyModule_AddObject(m, "WITH_PYMALLOC", Py_True);
v = Py_True;
#else
PyModule_AddObject(m, "WITH_PYMALLOC", Py_False);
v = Py_False;
#endif
Py_INCREF(v);
PyModule_AddObject(m, "WITH_PYMALLOC", v);

TestError = PyErr_NewException("_testcapi.error", NULL, NULL);
Py_INCREF(TestError);
Expand Down

0 comments on commit 84c36c1

Please sign in to comment.