There was an error while loading. Please reload this page.
1 parent 91daa9d commit 310e2d2Copy full SHA for 310e2d2
2 files changed
Modules/_testcapimodule.c
@@ -6721,11 +6721,14 @@ PyInit__testcapi(void)
6721
PyModule_AddObject(m, "instancemethod", (PyObject *)&PyInstanceMethod_Type);
6722
6723
PyModule_AddIntConstant(m, "the_number_three", 3);
6724
+ PyObject *v;
6725
#ifdef WITH_PYMALLOC
- PyModule_AddObject(m, "WITH_PYMALLOC", Py_True);
6726
+ v = Py_True;
6727
#else
- PyModule_AddObject(m, "WITH_PYMALLOC", Py_False);
6728
+ v = Py_False;
6729
#endif
6730
+ Py_INCREF(v);
6731
+ PyModule_AddObject(m, "WITH_PYMALLOC", v);
6732
6733
TestError = PyErr_NewException("_testcapi.error", NULL, NULL);
6734
Py_INCREF(TestError);
Python/pylifecycle.c
@@ -1210,6 +1210,14 @@ finalize_interp_clear(PyThreadState *tstate)
1210
{
1211
int is_main_interp = _Py_IsMainInterpreter(tstate);
1212
1213
+ /* bpo-36854: Explicitly clear the codec registry
1214
+ and trigger a GC collection */
1215
+ PyInterpreterState *interp = tstate->interp;
1216
+ Py_CLEAR(interp->codec_search_path);
1217
+ Py_CLEAR(interp->codec_search_cache);
1218
+ Py_CLEAR(interp->codec_error_registry);
1219
+ _PyGC_CollectNoFail();
1220
+
1221
/* Clear interpreter state and all thread states */
1222
PyInterpreterState_Clear(tstate->interp);
1223
0 commit comments