Skip to content

Commit f8713ec

Browse files
authored
Revert "bugfix: Keep registered types until after Py_Finalize(). Fix pybind#4459 (pybind#4486)" (pybind#4501)
This reverts commit b2c1978. See pybind#4500 for background.
1 parent 8a90b36 commit f8713ec

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

include/pybind11/embed.h

+2-5
Original file line numberDiff line numberDiff line change
@@ -254,16 +254,13 @@ inline void finalize_interpreter() {
254254
if (builtins.contains(id) && isinstance<capsule>(builtins[id])) {
255255
internals_ptr_ptr = capsule(builtins[id]);
256256
}
257-
258-
Py_Finalize();
259-
260257
// Local internals contains data managed by the current interpreter, so we must clear them to
261258
// 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
264259
detail::get_local_internals().registered_types_cpp.clear();
265260
detail::get_local_internals().registered_exception_translators.clear();
266261

262+
Py_Finalize();
263+
267264
if (internals_ptr_ptr) {
268265
delete *internals_ptr_ptr;
269266
*internals_ptr_ptr = nullptr;

0 commit comments

Comments
 (0)