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)
1702
1702
#endif
1703
1703
1704
1704
// 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
+ }
1707
1709
PyObject * modules = _PyImport_GetModules (interp );
1708
1710
if (modules == NULL ) {
1709
1711
// Already done
@@ -2377,15 +2379,13 @@ new_interpreter(PyThreadState **tstate_p,
2377
2379
error :
2378
2380
* tstate_p = NULL ;
2379
2381
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 );
2383
2385
}
2384
2386
if (save_tstate != NULL ) {
2385
2387
_PyThreadState_Attach (save_tstate );
2386
2388
}
2387
- PyInterpreterState_Delete (interp );
2388
-
2389
2389
return status ;
2390
2390
}
2391
2391
You can’t perform that action at this time.
0 commit comments