pybind/pybind11

[BUG]: Python atexit broken with pybind11 version >= 2.9.2

Open

#4,459 建立於 2023年1月17日

在 GitHub 查看
 (6 留言) (0 反應) (0 負責人)C++ (2,005 fork)batch import
bughelp wanted

倉庫指標

Star
 (14,677 star)
PR 合併指標
 (平均合併 5天 2小時) (30 天內合併 10 個 PR)

描述

Required prerequisites

What version (or hash if on master) of pybind11 are you using?

2.10.2

Problem description

We want to upgrade from pybind11 release 2.9.0 to 2.10.2, but we encountered an issue in the Python atexit (https://docs.python.org/3/library/atexit.html) functions, that our custom types are not registered anymore. With delta debugging we found that this PR caused the issue: https://github.com/pybind/pybind11/pull/3744

In my opinion the

    detail::get_local_internals().registered_types_cpp.clear();    
    detail::get_local_internals().registered_exception_translators.clear();

calls should be after the Py_Finalize function call.

When I change the orders of those function calls, the problem is gone.

Reproducible example code

No response

Is this a regression? Put the last known working version here if it is.

2.9.1

貢獻者指南