diff --git a/include/nanobind/stl/shared_ptr.h b/include/nanobind/stl/shared_ptr.h index 4b73ed93..a9a86542 100644 --- a/include/nanobind/stl/shared_ptr.h +++ b/include/nanobind/stl/shared_ptr.h @@ -19,7 +19,7 @@ NAMESPACE_BEGIN(detail) struct py_deleter { void operator()(void *) noexcept { // Don't run the deleter if the interpreter has been shut down - if (!Py_IsInitialized()) + if (!is_alive()) return; gil_scoped_acquire guard; Py_DECREF(o);