Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Modules/_testcapimodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -6721,11 +6721,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
8 changes: 8 additions & 0 deletions Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,14 @@ finalize_interp_clear(PyThreadState *tstate)
{
int is_main_interp = _Py_IsMainInterpreter(tstate);

/* bpo-36854: Explicitly clear the codec registry
and trigger a GC collection */
PyInterpreterState *interp = tstate->interp;
Py_CLEAR(interp->codec_search_path);
Py_CLEAR(interp->codec_search_cache);
Py_CLEAR(interp->codec_error_registry);
_PyGC_CollectNoFail();

/* Clear interpreter state and all thread states */
PyInterpreterState_Clear(tstate->interp);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, Can it be replaced by the newly declared variable?

PyInterpreterState_Clear(interp);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right, interp could be used. I hesitate between adding "interp" variables or using "tstate->interp" :-) I may change this in my next PR, I already merged this once before I read your comment, sorry.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the reply :)


Expand Down