I'm trying to build an exception class that I can use both in a C extension and the Python modules that import the extension. I'm using the PyErr_NewException to create the class as a superclass of the Exception class, but I can't figure out how to create an __init__
constructor for the class. I assume that is the best way to populate the class with t开发者_JS百科he attributes I need.
You should pass a dict
as the third argument to PyErr_NewException
. The dict should have an __init__
key bound to your initializer function.
精彩评论