Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Exception handling gets confused when Python code is called from destructor #1877
Given this .pyx code:
The Foo class calls the cb callback from its destructor, i.e. when the unique_ptr goes out of scope.
Complete example in the attached file cython-bug.zip. Execute with
The output that I get from running the example is:
This is using Cython version 0.26.1 on Linux.
added a commit
Sep 24, 2017
Honestly, this seems like the best fix already. Most C++ cleanup code does not do any Python interaction (in fact, most C++ cleanup code is probably trivial), so always storing away and (conditionally) restoring the current exception at the end of a function with stack allocated C++ objects would be a bit wasteful.
I'll keep this ticket open, because I agree that the current state is unsatisfactory, but it's not clear to me if we should do something about it.