@@ -286,9 +286,6 @@ PyInterpreterState_Clear(PyInterpreterState *interp)
286
286
}
287
287
HEAD_UNLOCK (runtime );
288
288
289
- PyObject * sysdict = interp -> sysdict ;
290
- PyObject * builtins = interp -> builtins ;
291
-
292
289
Py_CLEAR (interp -> audit_hooks );
293
290
294
291
PyConfig_Clear (& interp -> config );
@@ -297,6 +294,8 @@ PyInterpreterState_Clear(PyInterpreterState *interp)
297
294
Py_CLEAR (interp -> codec_error_registry );
298
295
Py_CLEAR (interp -> modules );
299
296
Py_CLEAR (interp -> modules_by_index );
297
+ PyDict_Clear (interp -> sysdict );
298
+ PyDict_Clear (interp -> builtins );
300
299
Py_CLEAR (interp -> sysdict );
301
300
Py_CLEAR (interp -> builtins );
302
301
Py_CLEAR (interp -> builtins_copy );
@@ -311,13 +310,6 @@ PyInterpreterState_Clear(PyInterpreterState *interp)
311
310
if (_PyRuntimeState_GetFinalizing (runtime ) == NULL ) {
312
311
_PyWarnings_Fini (interp );
313
312
}
314
-
315
- /* We don't clear sysdict and builtins until the end of this function.
316
- Because clearing
5F2D
other attributes can execute arbitrary Python code
317
- which requires sysdict and builtins. */
318
- PyDict_Clear (sysdict );
319
- PyDict_Clear (builtins );
320
-
321
313
// XXX Once we have one allocator per interpreter (i.e.
322
314
// per-interpreter GC) we must ensure that all of the interpreter's
323
315
// objects have been cleaned up at the point.
0 commit comments