Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
b3f28d48
Commit
b3f28d48
authored
Mar 30, 2021
by
Max Bachmann
Committed by
GitHub
Mar 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix type conversions in vectorcallfunc (GH-4054)
parent
03278313
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
17 deletions
+18
-17
Cython/Utility/CythonFunction.c
Cython/Utility/CythonFunction.c
+1
-1
Cython/Utility/ModuleSetupCode.c
Cython/Utility/ModuleSetupCode.c
+3
-3
Cython/Utility/ObjectHandling.c
Cython/Utility/ObjectHandling.c
+14
-13
No files found.
Cython/Utility/CythonFunction.c
View file @
b3f28d48
...
...
@@ -680,7 +680,7 @@ static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, P
__pyx_vectorcallfunc
vc
=
__Pyx_CyFunction_func_vectorcall
(
cyfunc
);
if
(
vc
)
{
#if CYTHON_ASSUME_SAFE_MACROS
return
__Pyx_PyVectorcall_FastCallDict
(
func
,
vc
,
&
PyTuple_GET_ITEM
(
args
,
0
),
PyTuple_GET_SIZE
(
args
),
kw
);
return
__Pyx_PyVectorcall_FastCallDict
(
func
,
vc
,
&
PyTuple_GET_ITEM
(
args
,
0
),
(
size_t
)
PyTuple_GET_SIZE
(
args
),
kw
);
#else
// avoid unused function warning
(
void
)
&
__Pyx_PyVectorcall_FastCallDict
;
...
...
Cython/Utility/ModuleSetupCode.c
View file @
b3f28d48
...
...
@@ -553,15 +553,15 @@ class __Pyx_FakeReference {
#if CYTHON_VECTORCALL
#define __pyx_vectorcallfunc vectorcallfunc
#define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET PY_VECTORCALL_ARGUMENTS_OFFSET
#define __Pyx_PyVectorcall_NARGS(n) PyVectorcall_NARGS(
n
)
#define __Pyx_PyVectorcall_NARGS(n) PyVectorcall_NARGS(
(size_t)(n)
)
#elif CYTHON_BACKPORT_VECTORCALL
typedef
PyObject
*
(
*
__pyx_vectorcallfunc
)(
PyObject
*
callable
,
PyObject
*
const
*
args
,
size_t
nargsf
,
PyObject
*
kwnames
);
#define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET ((size_t)1 << (8 * sizeof(size_t) - 1))
#define __Pyx_PyVectorcall_NARGS(n) ((
n) & ~__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET
)
#define __Pyx_PyVectorcall_NARGS(n) ((
Py_ssize_t)(((size_t)(n)) & ~__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)
)
#else
#define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET 0
#define __Pyx_PyVectorcall_NARGS(n) (
n
)
#define __Pyx_PyVectorcall_NARGS(n) (
(Py_ssize_t)(n)
)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
...
...
Cython/Utility/ObjectHandling.c
View file @
b3f28d48
...
...
@@ -2103,7 +2103,7 @@ bad:
/////////////// PyObjectFastCall.proto ///////////////
#define __Pyx_PyObject_FastCall(func, args, nargs) __Pyx_PyObject_FastCallDict(func, args, nargs, NULL)
static
CYTHON_INLINE
PyObject
*
__Pyx_PyObject_FastCallDict
(
PyObject
*
func
,
PyObject
**
args
,
Py_s
size_t
nargs
,
PyObject
*
kwargs
);
/*proto*/
static
CYTHON_INLINE
PyObject
*
__Pyx_PyObject_FastCallDict
(
PyObject
*
func
,
PyObject
**
args
,
size_t
nargs
,
PyObject
*
kwargs
);
/*proto*/
/////////////// PyObjectFastCall ///////////////
//@requires: PyObjectCall
...
...
@@ -2111,23 +2111,23 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObj
//@requires: PyObjectCallMethO
//@substitute: naming
static
PyObject
*
__Pyx_PyObject_FastCall_fallback
(
PyObject
*
func
,
PyObject
**
args
,
Py_s
size_t
nargs
,
PyObject
*
kwargs
)
{
static
PyObject
*
__Pyx_PyObject_FastCall_fallback
(
PyObject
*
func
,
PyObject
**
args
,
size_t
nargs
,
PyObject
*
kwargs
)
{
PyObject
*
argstuple
;
PyObject
*
result
;
Py_s
size_t
i
;
size_t
i
;
argstuple
=
PyTuple_New
(
nargs
);
if
(
unlikely
(
!
argstuple
))
return
NULL
;
for
(
i
=
0
;
i
<
nargs
;
i
++
)
{
Py_INCREF
(
args
[
i
]);
PyTuple_SET_ITEM
(
argstuple
,
i
,
args
[
i
]);
PyTuple_SET_ITEM
(
argstuple
,
(
Py_ssize_t
)
i
,
args
[
i
]);
}
result
=
__Pyx_PyObject_Call
(
func
,
argstuple
,
kwargs
);
Py_DECREF
(
argstuple
);
return
result
;
}
static
CYTHON_INLINE
PyObject
*
__Pyx_PyObject_FastCallDict
(
PyObject
*
func
,
PyObject
**
args
,
Py_s
size_t
_nargs
,
PyObject
*
kwargs
)
{
static
CYTHON_INLINE
PyObject
*
__Pyx_PyObject_FastCallDict
(
PyObject
*
func
,
PyObject
**
args
,
size_t
_nargs
,
PyObject
*
kwargs
)
{
// Special fast paths for 0 and 1 arguments
// NOTE: in many cases, this is called with a constant value for nargs
// which is known at compile-time. So the branches below will typically
...
...
@@ -2181,20 +2181,20 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObj
#if CYTHON_VECTORCALL
vectorcallfunc
f
=
_PyVectorcall_Function
(
func
);
if
(
f
)
{
return
f
(
func
,
args
,
nargs
,
kwargs
);
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
,
nargs
,
kwargs
);
if
(
f
)
return
f
(
func
,
args
,
(
size_t
)
nargs
,
kwargs
);
}
#endif
if
(
nargs
==
0
)
{
return
__Pyx_PyObject_Call
(
func
,
$
empty_tuple
,
kwargs
);
}
return
__Pyx_PyObject_FastCall_fallback
(
func
,
args
,
nargs
,
kwargs
);
return
__Pyx_PyObject_FastCall_fallback
(
func
,
args
,
(
size_t
)
nargs
,
kwargs
);
}
...
...
@@ -2559,14 +2559,14 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
/////////////// PyVectorcallFastCallDict.proto ///////////////
#if CYTHON_METH_FASTCALL
static
CYTHON_INLINE
PyObject
*
__Pyx_PyVectorcall_FastCallDict
(
PyObject
*
func
,
__pyx_vectorcallfunc
vc
,
PyObject
*
const
*
args
,
Py_s
size_t
nargs
,
PyObject
*
kw
);
static
CYTHON_INLINE
PyObject
*
__Pyx_PyVectorcall_FastCallDict
(
PyObject
*
func
,
__pyx_vectorcallfunc
vc
,
PyObject
*
const
*
args
,
size_t
nargs
,
PyObject
*
kw
);
#endif
/////////////// PyVectorcallFastCallDict ///////////////
#if CYTHON_METH_FASTCALL
// Slow path when kw is non-empty
static
PyObject
*
__Pyx_PyVectorcall_FastCallDict_kw
(
PyObject
*
func
,
__pyx_vectorcallfunc
vc
,
PyObject
*
const
*
args
,
Py_s
size_t
nargs
,
PyObject
*
kw
)
static
PyObject
*
__Pyx_PyVectorcall_FastCallDict_kw
(
PyObject
*
func
,
__pyx_vectorcallfunc
vc
,
PyObject
*
const
*
args
,
size_t
nargs
,
PyObject
*
kw
)
{
// Code based on _PyObject_FastCallDict() and _PyStack_UnpackDict() from CPython
PyObject
*
res
=
NULL
;
...
...
@@ -2574,17 +2574,18 @@ static PyObject *__Pyx_PyVectorcall_FastCallDict_kw(PyObject *func, __pyx_vector
PyObject
**
newargs
;
PyObject
**
kwvalues
;
Py_ssize_t
i
,
pos
;
size_t
j
;
PyObject
*
key
,
*
value
;
unsigned
long
keys_are_strings
;
Py_ssize_t
nkw
=
PyDict_GET_SIZE
(
kw
);
// Copy positional arguments
newargs
=
(
PyObject
**
)
PyMem_Malloc
((
nargs
+
nkw
)
*
sizeof
(
args
[
0
]));
newargs
=
(
PyObject
**
)
PyMem_Malloc
((
nargs
+
(
size_t
)
nkw
)
*
sizeof
(
args
[
0
]));
if
(
unlikely
(
newargs
==
NULL
))
{
PyErr_NoMemory
();
return
NULL
;
}
for
(
i
=
0
;
i
<
nargs
;
i
++
)
newargs
[
i
]
=
args
[
i
];
for
(
j
=
0
;
j
<
nargs
;
j
++
)
newargs
[
j
]
=
args
[
j
];
// Copy keyword arguments
kwnames
=
PyTuple_New
(
nkw
);
...
...
@@ -2619,7 +2620,7 @@ cleanup:
return
res
;
}
static
CYTHON_INLINE
PyObject
*
__Pyx_PyVectorcall_FastCallDict
(
PyObject
*
func
,
__pyx_vectorcallfunc
vc
,
PyObject
*
const
*
args
,
Py_s
size_t
nargs
,
PyObject
*
kw
)
static
CYTHON_INLINE
PyObject
*
__Pyx_PyVectorcall_FastCallDict
(
PyObject
*
func
,
__pyx_vectorcallfunc
vc
,
PyObject
*
const
*
args
,
size_t
nargs
,
PyObject
*
kw
)
{
if
(
likely
(
kw
==
NULL
)
||
PyDict_GET_SIZE
(
kw
)
==
0
)
{
return
vc
(
func
,
args
,
nargs
,
NULL
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment