Why Python doesn't catch exceptions raised in C++? -
I am trying to create a Python iterator in boost :: python. So I have the function
PyObject * my_iterator_next (MyIterator * iter) {if (! Iter- & gt; is_end ()) {return * (* iter) ++; } Other {PyErr_SetNone (PyExc_StopItation); // It does not work either PyErr_SetString (PyExc_StopItation, "End of Archive"); Return tap; }} In Python: MyContainer for X in and I can find:
1 2 3 No account pack (most recent call final): file "main.py", line 6, & lt ; Module & gt; Print (x) stop bitation: end of collection besides
this = my_collection .__ iter __ () try: it .__ next (__) ; This .__ next (__); This .__ next (__); This .__ next (__); This code does not print anything, so no exceptions have been captured.
Why?
After setting the dragon exception, you should notify Boost like this. Python is as follows:
throw_error_already_set (); View
Comments
Post a Comment