]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-39884: Add method name in "bad call flags" error (GH-18944) (GH-18956)
authorVictor Stinner <vstinner@python.org>
Thu, 12 Mar 2020 12:37:02 +0000 (13:37 +0100)
committerGitHub <noreply@github.com>
Thu, 12 Mar 2020 12:37:02 +0000 (13:37 +0100)
PyDescr_NewMethod() and PyCFunction_NewEx() now include the method
name in the SystemError "bad call flags" error message to ease debug.

(cherry picked from commit c7d2d69d95b263ee5f83511bc6fbe53acdc24ea3)

Misc/NEWS.d/next/C API/2020-03-12-00-27-26.bpo-39884.CGOJBO.rst [new file with mode: 0644]
Objects/descrobject.c
Objects/methodobject.c

diff --git a/Misc/NEWS.d/next/C API/2020-03-12-00-27-26.bpo-39884.CGOJBO.rst b/Misc/NEWS.d/next/C API/2020-03-12-00-27-26.bpo-39884.CGOJBO.rst
new file mode 100644 (file)
index 0000000..c65dfdc
--- /dev/null
@@ -0,0 +1,2 @@
+:c:func:`PyDescr_NewMethod` and :c:func:`PyCFunction_NewEx` now include the
+method name in the SystemError "bad call flags" error message to ease debug.
index 119be35db08d8ace574b98a04ec7f5eae3730f11..729f42c50c81432f525a5909c467571757b78ed6 100644 (file)
@@ -892,7 +892,8 @@ PyDescr_NewMethod(PyTypeObject *type, PyMethodDef *method)
             vectorcall = method_vectorcall_O;
             break;
         default:
-            PyErr_SetString(PyExc_SystemError, "bad call flags");
+            PyErr_Format(PyExc_SystemError,
+                         "%s() method: bad call flags", method->ml_name);
             return NULL;
     }
 
index 3494f11d80fe75967ce0601b08ab4e1ce1598963..3604a55e5a1dc9458346a619f3811737aa698c31 100644 (file)
@@ -62,7 +62,8 @@ PyCFunction_NewEx(PyMethodDef *ml, PyObject *self, PyObject *module)
             vectorcall = cfunction_vectorcall_O;
             break;
         default:
-            PyErr_SetString(PyExc_SystemError, "bad call flags");
+            PyErr_Format(PyExc_SystemError,
+                         "%s() method: bad call flags", ml->ml_name);
             return NULL;
     }