Commit 6a542fdf authored by Stefan Behnel's avatar Stefan Behnel

Repair calls to fused staticmethods : we currently generate the wrong C...

Repair calls to fused staticmethods : we currently generate the wrong C signature for them (first arg becomes 'self' arg), so this change works around that by really passing the first argument as 'self'.
Eventually, ths signature should be fixed instead.
parent 66ca26c4
......@@ -655,6 +655,7 @@ class FusedCFuncDefNode(StatListNode):
UtilityCode.declare_declarations_in_scope(
decl_code.getvalue(), env.global_scope())
ast.scope = env
# FIXME: for static methods of cdef classes, we build the wrong signature here: first arg becomes 'self'
ast.analyse_declarations(env)
py_func = ast.stats[-1] # the DefNode
self.fragment_scope = ast.scope
......
......@@ -1072,16 +1072,25 @@ __pyx_FusedFunction_call(PyObject *func, PyObject *args, PyObject *kw)
#endif
if (binding_func->__signatures__) {
PyObject *tup = PyTuple_Pack(4, binding_func->__signatures__, args,
PyObject *tup;
if (is_staticmethod && binding_func->func.flags & __Pyx_CYFUNCTION_CCLASS) {
// FIXME: this seems wrong, but we must currently pass the signatures dict as 'self' argument
tup = PyTuple_Pack(3, args,
kw == NULL ? Py_None : kw,
binding_func->func.defaults_tuple);
if (!tup)
goto bad;
if (unlikely(!tup)) goto bad;
new_func = (__pyx_FusedFunctionObject *) __Pyx_CyFunction_CallMethod(
func, binding_func->__signatures__, tup, NULL);
} else {
tup = PyTuple_Pack(4, binding_func->__signatures__, args,
kw == NULL ? Py_None : kw,
binding_func->func.defaults_tuple);
if (unlikely(!tup)) goto bad;
new_func = (__pyx_FusedFunctionObject *) __pyx_FusedFunction_callfunction(func, tup, NULL);
}
Py_DECREF(tup);
if (!new_func)
if (unlikely(!new_func))
goto bad;
Py_XINCREF(binding_func->func.func_classobj);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment