summaryrefslogtreecommitdiff
path: root/Cython/Utility/CythonFunction.c
diff options
context:
space:
mode:
Diffstat (limited to 'Cython/Utility/CythonFunction.c')
-rw-r--r--Cython/Utility/CythonFunction.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/Cython/Utility/CythonFunction.c b/Cython/Utility/CythonFunction.c
index 9a7bf7405..226019cee 100644
--- a/Cython/Utility/CythonFunction.c
+++ b/Cython/Utility/CythonFunction.c
@@ -780,9 +780,17 @@ static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, P
self = PyTuple_GetItem(args, 0);
if (unlikely(!self)) {
Py_DECREF(new_args);
+#if PY_MAJOR_VERSION > 2
PyErr_Format(PyExc_TypeError,
"unbound method %.200S() needs an argument",
cyfunc->func_qualname);
+#else
+ // %S doesn't work in PyErr_Format on Py2 and replicating
+ // the formatting seems more trouble than it's worth
+ // (so produce a less useful error message).
+ PyErr_SetString(PyExc_TypeError,
+ "unbound method needs an argument");
+#endif
return NULL;
}
@@ -934,7 +942,7 @@ static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject
return NULL;
}
- return ((__Pyx_PyCMethod)(void(*)(void))def->ml_meth)(self, cls, args, nargs, kwnames);
+ return ((__Pyx_PyCMethod)(void(*)(void))def->ml_meth)(self, cls, args, (size_t)nargs, kwnames);
}
#endif
@@ -1055,7 +1063,7 @@ static int __pyx_CyFunction_init(PyObject *module) {
#if CYTHON_USE_TYPE_SPECS
__pyx_CyFunctionType = __Pyx_FetchCommonTypeFromSpec(module, &__pyx_CyFunctionType_spec, NULL);
#else
- (void) module;
+ CYTHON_UNUSED_VAR(module);
__pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
#endif
if (unlikely(__pyx_CyFunctionType == NULL)) {
@@ -1463,30 +1471,17 @@ bad:
return result;
}
-static PyObject *
-__Pyx_FusedFunction_get_self(__pyx_FusedFunctionObject *m, void *closure)
-{
- PyObject *self = m->self;
- CYTHON_UNUSED_VAR(closure);
- if (unlikely(!self)) {
- PyErr_SetString(PyExc_AttributeError, "'function' object has no attribute '__self__'");
- } else {
- Py_INCREF(self);
- }
- return self;
-}
-
static PyMemberDef __pyx_FusedFunction_members[] = {
{(char *) "__signatures__",
T_OBJECT,
offsetof(__pyx_FusedFunctionObject, __signatures__),
READONLY,
0},
+ {(char *) "__self__", T_OBJECT_EX, offsetof(__pyx_FusedFunctionObject, self), READONLY, 0},
{0, 0, 0, 0, 0},
};
static PyGetSetDef __pyx_FusedFunction_getsets[] = {
- {(char *) "__self__", (getter)__Pyx_FusedFunction_get_self, 0, 0, 0},
// __doc__ is None for the fused function type, but we need it to be
// a descriptor for the instance's __doc__, so rebuild the descriptor in our subclass
// (all other descriptors are inherited)
@@ -1600,7 +1595,7 @@ static int __pyx_FusedFunction_init(PyObject *module) {
__pyx_FusedFunctionType = __Pyx_FetchCommonTypeFromSpec(module, &__pyx_FusedFunctionType_spec, bases);
Py_DECREF(bases);
#else
- (void) module;
+ CYTHON_UNUSED_VAR(module);
// Set base from __Pyx_FetchCommonTypeFromSpec, in case it's different from the local static value.
__pyx_FusedFunctionType_type.tp_base = __pyx_CyFunctionType;
__pyx_FusedFunctionType = __Pyx_FetchCommonType(&__pyx_FusedFunctionType_type);
@@ -1614,7 +1609,7 @@ static int __pyx_FusedFunction_init(PyObject *module) {
//////////////////// ClassMethod.proto ////////////////////
#include "descrobject.h"
-static CYTHON_UNUSED PyObject* __Pyx_Method_ClassMethod(PyObject *method); /*proto*/
+CYTHON_UNUSED static PyObject* __Pyx_Method_ClassMethod(PyObject *method); /*proto*/
//////////////////// ClassMethod ////////////////////