Is there a way to pass a reference to python, that will raise an exception if used after the python function returns? #3192
daltairwalter
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a C++ object that I am trying to use in a trampoline function. If I pass it directly by reference, I see:
return_value_policy = copy, but type ... is non-copyable!
If I change what I am passing to a pointer, the code works, but if I store the object in python, I see a crash if this object is used later. Instead of a crash, I would like to see a python exception that says the objects lifetime has expired.
I think I could do this by using a lambda in all of the def calls, but I am wondering if there is an easier way.
Beta Was this translation helpful? Give feedback.
All reactions