Skip to content

Commit f128f1b

Browse files
committed
Converting C assert to pybind11_fail (to play safe).
1 parent 5af253d commit f128f1b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

include/pybind11/detail/smart_holder_type_casters.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "type_caster_base.h"
1919
#include "typeid.h"
2020

21-
#include <cassert>
2221
#include <cstddef>
2322
#include <memory>
2423
#include <new>
@@ -419,8 +418,10 @@ struct smart_holder_type_caster_load {
419418
if (sptsls_ptr != nullptr) {
420419
// This code is reachable only if there are multiple registered_instances for the
421420
// same pointee.
422-
assert(reinterpret_cast<PyObject *>(load_impl.loaded_v_h.inst)
423-
!= sptsls_ptr->self);
421+
if (reinterpret_cast<PyObject *>(load_impl.loaded_v_h.inst) == sptsls_ptr->self) {
422+
pybind11_fail("smart_holder_type_casters loaded_as_shared_ptr failure: "
423+
"load_impl.loaded_v_h.inst == sptsls_ptr->self");
424+
}
424425
return std::shared_ptr<T>(
425426
type_raw_ptr,
426427
shared_ptr_trampoline_self_life_support(load_impl.loaded_v_h.inst));

0 commit comments

Comments
 (0)