C扩展Python
使用C扩展Python PyErr_*()函数是将一个异常对象压入到Python解释器的异常栈中 PyErr_Clear()函数是将Python异常栈中栈顶的元素弹出, 调用这个函数通常就相当于在Python程序中的try: except: 语句中except的作用 Python中的API, 每一个模块对应的API是PyMODNAME_FUNCINMOD() Python扩展模块的函数模板: // First static PyObject *exfunc(PyObject *self, PyObject *args) { ... // Get parameters /* Return 0 means an exception has been raised, you need to stop your program and rreturn NULL According to the official: It returns NULL (the error indicator for functions returning object pointers) if an error i...