> 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? I guess so. The rule is that all PyErr_SetXXX functions correspond to a raise statement with a class as first argument. raise with an instance first argument is a shortcut. > Also, it looks as if exceptions have to be > old-style instances, not new-style ones. Is > that correct? Unfortunately so in the current code base. I'm not sure if/when we should lift this restriction. I'm also not sure if, when we lift it, we should make Exception and all other built-in exceptions new-style classes. New-style and classic classes aren't 100% compatible and I don't like to break people's code who have subclassed a built-in exception class and did something that doesn't work the same in new-style classes. --Guido van Rossum (home page: http://www.python.org/~guido/)
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