1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
From 81cc077ad035947a3429c245f1e28c8b43c6dcc6 Mon Sep 17 00:00:00 2001
From: da-woods <dw-git@d-woods.co.uk>
Date: Sat, 2 Sep 2023 10:32:59 +0100
Subject: [PATCH] Fix invalid fastcall dict when keywords are passed
Fixes #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.
---
Cython/Utility/ObjectHandling.c | 36 +++++++++++++++++++--------------
1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/Cython/Utility/ObjectHandling.c b/Cython/Utility/ObjectHandling.c
index 8ea5be42935..507fb94f605 100644
--- a/Cython/Utility/ObjectHandling.c
+++ b/Cython/Utility/ObjectHandling.c
@@ -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
}
|