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 @@ -1702,8 +1702,10 @@ finalize_modules(PyThreadState *tstate)
17021702#endif
17031703
17041704 // Stop watching __builtin__ modifications
1705- PyDict_Unwatch (0 , interp -> builtins );
1706-
1705+ if (PyDict_Unwatch (0 , interp -> builtins ) < 0 ) {
1706+ // might happen if interp is cleared before watching the __builtin__
1707+ PyErr_Clear ();
1708+ }
17071709 PyObject * modules = _PyImport_GetModules (interp );
17081710 if (modules == NULL ) {
17091711 // Already done
@@ -2377,15 +2379,13 @@ new_interpreter(PyThreadState **tstate_p,
23772379error :
23782380 * tstate_p = NULL ;
23792381 if (tstate != NULL ) {
2380- PyThreadState_Clear (tstate );
2381- _PyThreadState_Detach ( tstate );
2382- PyThreadState_Delete ( tstate );
2382+ Py_EndInterpreter (tstate );
2383+ } else {
2384+ PyInterpreterState_Delete ( interp );
23832385 }
23842386 if (save_tstate != NULL ) {
23852387 _PyThreadState_Attach (save_tstate );
23862388 }
2387- PyInterpreterState_Delete (interp );
2388-
23892389 return status ;
23902390}
23912391
You can’t perform that action at this time.
0 commit comments