summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2019-11-22 12:39:36 (GMT)
committerGitHub <noreply@github.com>2019-11-22 12:39:36 (GMT)
commit84c36c152a2bdf98f9cc7ce0e1db98e1f442a05e (patch)
tree5cff8ddb23afa252ac3b4f6d73d037484e7fba07 /Modules
parent107ed88cde3ae6f1cb01ae75575ea0f92c138464 (diff)
downloadcpython-84c36c152a2bdf98f9cc7ce0e1db98e1f442a05e.zip
cpython-84c36c152a2bdf98f9cc7ce0e1db98e1f442a05e.tar.gz
cpython-84c36c152a2bdf98f9cc7ce0e1db98e1f442a05e.tar.bz2
bpo-36854: Fix reference counter in PyInit__testcapi() (GH-17338)
Increment properly Py_True/Py_False reference counter for _testcapi.WITH_PYMALLOC variable.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_testcapimodule.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 46d772c..b540716 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -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);