Guido: > It seems that this is just for > > raise TypeError, "Test-Exception" Actually, it's raise TypeError("Test-Exception") > But I think that you shouldn't be calling PyErr_SetNone() here -- I > think you should call PyErr_SetObject(__pyx_1, __pyx_2). > > For details see do_raise() in ceval.c. Hmmm. Having studied this routine *very* carefully, I think I can see where things are going wrong. Reading the C API docs led me to believe that the equivalent of the Python statement raise x would be PyErr_SetNone(x) But it appears that is not the case, and what I should actually be doing is PyErr_SetObject( ((PyInstanceObject*)x)->in_class, x) This is... um... not very intuitive. Perhaps the C API docs could be amended to mention this? Also, it looks as if exceptions have to be old-style instances, not new-style ones. Is that correct? Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg@cosc.canterbury.ac.nz +--------------------------------------+
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4