fix: Guard against using a uninitialized value after `__new__` allocating python object
fixes: #6153
Objects initialized with `cls.__new__(cls)` (`cls` is a pybind11 bound
type). Will not have the C++ object allocated. When hitting `load_value`
storage is allocated but not initialized, calling a virtual method will
load a garbage vptr and segfault. This is similar to #2152, but the
guard in metaclass `__call__` is not triggered when using `__new__`.
Protect against giving a pointer to garbage in all cases except the
`__init__` + `__setstate__` path.
Authored with claude
6 files changed