File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -1717,8 +1717,10 @@ finalize_modules(PyThreadState *tstate)
17171717#endif
17181718
17191719 // Stop watching __builtin__ modifications
1720- PyDict_Unwatch (0 , interp -> builtins );
1721-
1720+ if (PyDict_Unwatch (0 , interp -> builtins ) < 0 ) {
1721+ // might happen if interp is cleared before watching the __builtin__
1722+ PyErr_Clear ();
1723+ }
17221724 PyObject * modules = _PyImport_GetModules (interp );
17231725 if (modules == NULL ) {
17241726 // Already done
@@ -2385,15 +2387,13 @@ new_interpreter(PyThreadState **tstate_p,
23852387error :
23862388 * tstate_p = NULL ;
23872389 if (tstate != NULL ) {
2388- PyThreadState_Clear (tstate );
2389- _PyThreadState_Detach ( tstate );
2390- PyThreadState_Delete ( tstate );
2390+ Py_EndInterpreter (tstate );
2391+ } else {
2392+ PyInterpreterState_Delete ( interp );
23912393 }
23922394 if (save_tstate != NULL ) {
23932395 _PyThreadState_Attach (save_tstate );
23942396 }
2395- PyInterpreterState_Delete (interp );
2396-
23972397 return status ;
23982398}
23992399
You can’t perform that action at this time.
0 commit comments