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
Gwenaël Samain
cython
Commits
a286151e
Commit
a286151e
authored
Apr 08, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
copied PyCFunction_Call() from CPython to be used when compiling for PyPy
parent
079d698d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
1 deletion
+54
-1
Cython/Utility/CythonFunction.c
Cython/Utility/CythonFunction.c
+54
-1
No files found.
Cython/Utility/CythonFunction.c
View file @
a286151e
...
...
@@ -392,6 +392,59 @@ __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
#endif
}
#if CYTHON_COMPILING_IN_PYPY
/* originally copied from PyCFunction_Call() in CPython's Objects/methodobject.c */
/* PyPy does not have this function */
static
PyObject
*
__Pyx_CyFunction_Call
(
PyObject
*
func
,
PyObject
*
arg
,
PyObject
*
kw
)
{
PyCFunctionObject
*
f
=
(
PyCFunctionObject
*
)
func
;
PyCFunction
meth
=
PyCFunction_GET_FUNCTION
(
func
);
PyObject
*
self
=
PyCFunction_GET_SELF
(
func
);
Py_ssize_t
size
;
switch
(
PyCFunction_GET_FLAGS
(
func
)
&
~
(
METH_CLASS
|
METH_STATIC
|
METH_COEXIST
))
{
case
METH_VARARGS
:
if
(
likely
(
kw
==
NULL
)
||
PyDict_Size
(
kw
)
==
0
)
return
(
*
meth
)(
self
,
arg
);
break
;
case
METH_VARARGS
|
METH_KEYWORDS
:
return
(
*
(
PyCFunctionWithKeywords
)
meth
)(
self
,
arg
,
kw
);
case
METH_NOARGS
:
if
(
likely
(
kw
==
NULL
)
||
PyDict_Size
(
kw
)
==
0
)
{
size
=
PyTuple_GET_SIZE
(
arg
);
if
(
size
==
0
)
return
(
*
meth
)(
self
,
NULL
);
PyErr_Format
(
PyExc_TypeError
,
"%.200s() takes no arguments (%zd given)"
,
f
->
m_ml
->
ml_name
,
size
);
return
NULL
;
}
break
;
case
METH_O
:
if
(
likely
(
kw
==
NULL
)
||
PyDict_Size
(
kw
)
==
0
)
{
size
=
PyTuple_GET_SIZE
(
arg
);
if
(
size
==
1
)
return
(
*
meth
)(
self
,
PyTuple_GET_ITEM
(
arg
,
0
));
PyErr_Format
(
PyExc_TypeError
,
"%.200s() takes exactly one argument (%zd given)"
,
f
->
m_ml
->
ml_name
,
size
);
return
NULL
;
}
break
;
default:
PyErr_SetString
(
PyExc_SystemError
,
"Bad call flags in "
"__Pyx_CyFunction_Call. METH_OLDARGS is no "
"longer supported!"
);
return
NULL
;
}
PyErr_Format
(
PyExc_TypeError
,
"%.200s() takes no keyword arguments"
,
f
->
m_ml
->
ml_name
);
return
NULL
;
}
#else
#define __Pyx_CyFunction_Call PyCFunction_Call
#endif
static
PyTypeObject
__pyx_CyFunctionType_type
=
{
PyVarObject_HEAD_INIT
(
0
,
0
)
__Pyx_NAMESTR
(
"cython_function_or_method"
),
/*tp_name*/
...
...
@@ -411,7 +464,7 @@ static PyTypeObject __pyx_CyFunctionType_type = {
0
,
/*tp_as_sequence*/
0
,
/*tp_as_mapping*/
0
,
/*tp_hash*/
__Pyx_
PyCFunction_Call
,
/*tp_call*/
__Pyx_
CyFunction_Call
,
/*tp_call*/
0
,
/*tp_str*/
0
,
/*tp_getattro*/
0
,
/*tp_setattro*/
...
...
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