MCPcopy Create free account
hub / github.com/pybind/pybind11 / dealloc_impl

Method dealloc_impl

include/pybind11/pybind11.h:2840–2849  ·  view source on GitHub ↗

Deallocates an instance; via holder, if constructed; otherwise via operator delete. NOTE: The Python error indicator needs to cleared BEFORE this function is called. This is because we could be deallocating while cleaning up after a Python exception. If the error indicator is not cleared but the C++ destructor code makes Python C API calls, those calls are likely to generate a new exception, and p

Source from the content-addressed store, hash-verified

2838 // throw `error_already_set` from the C++ destructor. This is forbidden and will
2839 // trigger std::terminate().
2840 static void dealloc_impl(detail::value_and_holder &v_h) {
2841 if (v_h.holder_constructed()) {
2842 v_h.holder<holder_type>().~holder_type();
2843 v_h.set_holder_constructed(false);
2844 } else {
2845 detail::call_operator_delete(
2846 v_h.value_ptr<type>(), v_h.type->type_size, v_h.type->type_align);
2847 }
2848 v_h.value_ptr() = nullptr;
2849 }
2850
2851 static void dealloc_without_manipulating_gil(detail::value_and_holder &v_h) {
2852 error_scope scope;

Callers

nothing calls this directly

Calls 3

call_operator_deleteFunction · 0.85
holder_constructedMethod · 0.80

Tested by

no test coverage detected