如何编写一个对内置Exception
类进行子类化的扩展类?
我试过
cdef extern from "Python.h" nogil:
ctypedef class __builtin__.Exception [object PyExc_Exception]:
pass
cdef class FUSEError(Exception):
cdef public int errno
从.pyx
到.c
编译好,但.c
文件的编译失败,
src/llfuse/cext_linux.c:495:3: error: expected specifier-qualifier-list before ‘PyExc_Exception’
PyExc_Exception __pyx_base;
我猜这意味着PyExc_Exception实际上并不是名字 C struct for Exception - 但它是什么? https://docs.python.org/3.6/c-api/exceptions.html#standard-exceptions 似乎清楚地说它是PyExc_Exception ..