File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -254,13 +254,15 @@ 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 after Py_Finalize() so atexit and other hooks can use registered_types
259
263
detail::get_local_internals ().registered_types_cpp .clear ();
260
264
detail::get_local_internals ().registered_exception_translators .clear ();
261
265
262
- Py_Finalize ();
263
-
264
266
if (internals_ptr_ptr) {
265
267
delete *internals_ptr_ptr;
266
268
*internals_ptr_ptr = nullptr ;
You can’t perform that action at this time.
0 commit comments