code.putln('static char %s[] = "%s";' % (
env.doc_cname, escape_byte_string(docstr)))
- env.use_utility_code(streq_utility_code)
-
# XXX this is a mess
for utility_code in PyrexTypes.c_int_from_py_function.specialize_list:
env.use_utility_code(utility_code)
code.putln("static void %s(void); /*proto*/" % Naming.fileinit_cname)
def generate_import_star(self, env, code):
+ env.use_utility_code(streq_utility_code)
code.putln()
code.putln("char* %s_type_names[] = {" % Naming.import_star)
for name, entry in env.entries.items():
impl = """
static PyObject* __Pyx_Method_ClassMethod(PyObject *method) {
/* It appears that PyMethodDescr_Type is not anywhere exposed in the Python/C API */
- /* if (!PyObject_TypeCheck(method, &PyMethodDescr_Type)) { */
- if (__Pyx_StrEq(Py_TYPE(method)->tp_name, "method_descriptor")) { /* cdef classes */
+ static PyTypeObject *methoddescr_type = NULL;
+ if (methoddescr_type == NULL) {
+ PyObject *meth = __Pyx_GetAttrString((PyObject*)&PyList_Type, "append");
+ if (!meth) return NULL;
+ methoddescr_type = Py_TYPE(meth);
+ Py_DECREF(meth);
+ }
+ if (PyObject_TypeCheck(method, methoddescr_type)) { /* cdef classes */
PyMethodDescrObject *descr = (PyMethodDescrObject *)method;
return PyDescr_NewClassMethod(descr->d_type, descr->d_method);
}