diff options
author | da-woods <dw-git@d-woods.co.uk> | 2022-10-04 19:55:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-04 19:55:28 +0100 |
commit | 5266b9c929a3e8348998b70df7561c0d7c3a0758 (patch) | |
tree | e37889ae1e2d61d5549fd76186fc9e78e0c0fcd4 | |
parent | d0b95046274f6d800b808e479a818cd1d03fba51 (diff) | |
download | cython-5266b9c929a3e8348998b70df7561c0d7c3a0758.tar.gz |
"Fix" an exception formatting issue on Py2 (#5018)
-rw-r--r-- | Cython/Utility/CythonFunction.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Cython/Utility/CythonFunction.c b/Cython/Utility/CythonFunction.c index b2c67dcce..dbe9a0a9d 100644 --- a/Cython/Utility/CythonFunction.c +++ b/Cython/Utility/CythonFunction.c @@ -660,9 +660,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; } |