diff options
-rw-r--r-- | Cython/Utility/CythonFunction.c | 3 | ||||
-rw-r--r-- | tests/run/cyfunction.pyx | 6 |
2 files changed, 9 insertions, 0 deletions
diff --git a/Cython/Utility/CythonFunction.c b/Cython/Utility/CythonFunction.c index 5ea48ea94..b2c67dcce 100644 --- a/Cython/Utility/CythonFunction.c +++ b/Cython/Utility/CythonFunction.c @@ -660,6 +660,9 @@ static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, P self = PyTuple_GetItem(args, 0); if (unlikely(!self)) { Py_DECREF(new_args); + PyErr_Format(PyExc_TypeError, + "unbound method %.200S() needs an argument", + cyfunc->func_qualname); return NULL; } diff --git a/tests/run/cyfunction.pyx b/tests/run/cyfunction.pyx index 3811b2694..f61dddb53 100644 --- a/tests/run/cyfunction.pyx +++ b/tests/run/cyfunction.pyx @@ -363,6 +363,9 @@ cdef class TestUnboundMethodCdef: >>> C = TestUnboundMethodCdef >>> IS_PY2 or (C.meth is C.__dict__["meth"]) True + >>> TestUnboundMethodCdef.meth() # doctest:+ELLIPSIS + Traceback (most recent call last): + TypeError: ... """ def meth(self): pass @@ -372,6 +375,9 @@ class TestUnboundMethod: >>> C = TestUnboundMethod >>> IS_PY2 or (C.meth is C.__dict__["meth"]) True + >>> TestUnboundMethod.meth() # doctest:+ELLIPSIS + Traceback (most recent call last): + TypeError: ... """ def meth(self): pass |