Cython:如何编写扩展类子类化`Exception`

时间:2015-08-30 21:50:39

标签: python cython

如何编写一个对内置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 ..

0 个答案:

没有答案