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)
1717
1717
#endif
1718
1718
1719
1719
// 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
+ }
1722
1724
PyObject * modules = _PyImport_GetModules (interp );
1723
1725
if (modules == NULL ) {
1724
1726
// Already done
@@ -2385,15 +2387,13 @@ new_interpreter(PyThreadState **tstate_p,
2385
2387
error :
2386
2388
* tstate_p = NULL ;
2387
2389
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 );
2391
2393
}
2392
2394
if (save_tstate != NULL ) {
2393
2395
_PyThreadState_Attach (save_tstate );
2394
2396
}
2395
- PyInterpreterState_Delete (interp );
2396
-
2397
2397
return status ;
2398
2398
}
2399
2399
You can’t perform that action at this time.
0 commit comments