mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 05:05:11 +00:00
don't throw an exception when python deallocates an object which still exists on the C++ side
This commit is contained in:
parent
6d6fd099db
commit
ac0fde988a
@ -292,6 +292,9 @@ public:
|
||||
PYBIND_TYPE_CASTER(void_type, "None");
|
||||
};
|
||||
|
||||
template <> class type_caster<void> : public type_caster<void_type> {
|
||||
};
|
||||
|
||||
template <> class type_caster<bool> {
|
||||
public:
|
||||
bool load(PyObject *src, bool) {
|
||||
|
@ -883,6 +883,8 @@ public:
|
||||
|
||||
inline function get_overload(const void *this_ptr, const char *name) {
|
||||
handle py_object = detail::get_object_handle(this_ptr);
|
||||
if (!py_object)
|
||||
return function();
|
||||
handle type = py_object.get_type();
|
||||
auto key = std::make_pair(type.ptr(), name);
|
||||
|
||||
|
@ -400,7 +400,7 @@ inline handle get_object_handle(const void *ptr) {
|
||||
auto instances = get_internals().registered_instances;
|
||||
auto it = instances.find(ptr);
|
||||
if (it == instances.end())
|
||||
throw std::runtime_error("Internal error: could not acquire Python handle of a C++ object");
|
||||
return handle();
|
||||
return it->second;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user