When investigating some issue with decorators, I noticed the following
stange thing: it seems that the @staticmethod decorator is actually
applied twice in some cases. For example, the testsuite file
tests/run/static_methods.pyx contains the following code:
cdef class A:
@staticmethod
def static_def(int x):
...
The relevant part of the Cython-generated code:
__pyx_t_1 =
PyCFunction_NewEx(&__pyx_mdef_14static_methods_1A_1static_def, NULL,
__pyx_n_s_static_methods);
...
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_staticmethod,
__pyx_t_2, NULL);
...
if (PyDict_SetItem((PyObject
*)__pyx_ptype_14static_methods_A->tp_dict, __pyx_n_s_static_def,
__pyx_t_1) < 0)
...
__pyx_t_1 = __Pyx_GetNameInClass((PyObject
*)__pyx_ptype_14static_methods_A, __pyx_n_s_static_def);
...
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_staticmethod,
__pyx_t_2, NULL);
...
if (PyDict_SetItem((PyObject
*)__pyx_ptype_14static_methods_A->tp_dict, __pyx_n_s_static_def,
__pyx_t_1) < 0)
I might be missing something, but this really looks like Cython is
applying the @staticmethod decorator twice.
_______________________________________________
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel