File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -254,13 +254,16 @@ inline void finalize_interpreter() {
254
254
if (builtins.contains (id) && isinstance<capsule>(builtins[id])) {
255
255
internals_ptr_ptr = capsule (builtins[id]);
256
256
}
257
+
258
+ Py_Finalize ();
259
+
257
260
// Local internals contains data managed by the current interpreter, so we must clear them to
258
261
// avoid undefined behaviors when initializing another interpreter
262
+ // Must be cleared only after Py_Finalize() so atexit and other hooks can still use
263
+ // registered_types
259
264
detail::get_local_internals ().registered_types_cpp .clear ();
260
265
detail::get_local_internals ().registered_exception_translators .clear ();
261
266
262
- Py_Finalize ();
263
-
264
267
if (internals_ptr_ptr) {
265
268
delete *internals_ptr_ptr;
266
269
*internals_ptr_ptr = nullptr ;
You can’t perform that action at this time.
0 commit comments