Closed mkolin closed 8 months ago
I see ... two different code paths. The first goes to the default __bool__
implementation (__nonzero__
) which is a Python method and does internally a null check to determine True
or False
. In the second case, operator bool()
is mapped to __bool__
, making it a C++ method, in which case the null check is performed before calling the method (to prevent segfaults), hence the ReferenceError
(just like for any other C++ method).
It's probably reasonable to treat __bool__
as a special case.
Fixed in repo.
Released with release 3.1.0.
When a type has an
operator bool()
method, cppyy doesn't seem to check for nullptr and will throw.It would be nice if we can check for nullptr and then call the
operator bool()
to ensure we don't get aReferenceError
exception.Tested with cppyy 2.4.2