Skip to content

Commit

Permalink
Fix invalid fastcall dict when keywords are passed
Browse files Browse the repository at this point in the history
Fixes cython#5665

I'm slightly surprised this hasn't caused more bugs. We're passing
a dict where we should be passing a tuple of names.

Replacement should hopefully be right, but I don't know how
optimized or otherwise it is.
  • Loading branch information
da-woods committed Sep 2, 2023
1 parent 6f59264 commit 81cc077
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions Cython/Utility/ObjectHandling.c
Expand Up @@ -2328,27 +2328,33 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObj
#endif
#endif

#if CYTHON_VECTORCALL
#if Py_VERSION_HEX < 0x03090000
vectorcallfunc f = _PyVectorcall_Function(func);
#else
vectorcallfunc f = PyVectorcall_Function(func);
#endif
if (f) {
return f(func, args, (size_t)nargs, kwargs);
}
#elif defined(__Pyx_CyFunction_USED) && CYTHON_BACKPORT_VECTORCALL
// exclude fused functions for now
if (__Pyx_CyFunction_CheckExact(func)) {
__pyx_vectorcallfunc f = __Pyx_CyFunction_func_vectorcall(func);
if (f) return f(func, args, (size_t)nargs, kwargs);
if (kwargs == NULL) {
#if CYTHON_VECTORCALL
#if Py_VERSION_HEX < 0x03090000
vectorcallfunc f = _PyVectorcall_Function(func);
#else
vectorcallfunc f = PyVectorcall_Function(func);
#endif
if (f) {
return f(func, args, (size_t)nargs, NULL);
}
#elif defined(__Pyx_CyFunction_USED) && CYTHON_BACKPORT_VECTORCALL
// exclude fused functions for now
if (__Pyx_CyFunction_CheckExact(func)) {
__pyx_vectorcallfunc f = __Pyx_CyFunction_func_vectorcall(func);
if (f) return f(func, args, (size_t)nargs, NULL);
}
#endif
}
#endif

if (nargs == 0) {
return __Pyx_PyObject_Call(func, $empty_tuple, kwargs);
}
#if PY_VERSION_HEX >= 0x03090000 && !CYTHON_COMPILING_IN_LIMITED_API
return PyObject_VectorcallDict(func, args, nargs, kwargs);
#else
return __Pyx_PyObject_FastCall_fallback(func, args, (size_t)nargs, kwargs);
#endif
}


Expand Down

0 comments on commit 81cc077

Please sign in to comment.