mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-27 07:32:02 +00:00
Merge branch 'pybind:master' into master
This commit is contained in:
commit
e7d7fc5760
@ -198,6 +198,10 @@ inline void finalize_interpreter() {
|
|||||||
if (builtins.contains(id) && isinstance<capsule>(builtins[id])) {
|
if (builtins.contains(id) && isinstance<capsule>(builtins[id])) {
|
||||||
internals_ptr_ptr = capsule(builtins[id]);
|
internals_ptr_ptr = capsule(builtins[id]);
|
||||||
}
|
}
|
||||||
|
// Local internals contains data managed by the current interpreter, so we must clear them to
|
||||||
|
// avoid undefined behaviors when initializing another interpreter
|
||||||
|
detail::get_local_internals().registered_types_cpp.clear();
|
||||||
|
detail::get_local_internals().registered_exception_translators.clear();
|
||||||
|
|
||||||
Py_Finalize();
|
Py_Finalize();
|
||||||
|
|
||||||
|
@ -375,3 +375,21 @@ TEST_CASE("sys.argv gets initialized properly") {
|
|||||||
}
|
}
|
||||||
py::initialize_interpreter();
|
py::initialize_interpreter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("make_iterator can be called before then after finalizing an interpreter") {
|
||||||
|
// Reproduction of issue #2101 (https://github.com/pybind/pybind11/issues/2101)
|
||||||
|
py::finalize_interpreter();
|
||||||
|
|
||||||
|
std::vector<int> container;
|
||||||
|
{
|
||||||
|
pybind11::scoped_interpreter g;
|
||||||
|
auto iter = pybind11::make_iterator(container.begin(), container.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
REQUIRE_NOTHROW([&]() {
|
||||||
|
pybind11::scoped_interpreter g;
|
||||||
|
auto iter = pybind11::make_iterator(container.begin(), container.end());
|
||||||
|
}());
|
||||||
|
|
||||||
|
py::initialize_interpreter();
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user