]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46431: improve error message on invalid calls to BaseExceptionGroup.__new__ ...
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>
Mon, 24 Jan 2022 21:47:40 +0000 (21:47 +0000)
committerGitHub <noreply@github.com>
Mon, 24 Jan 2022 21:47:40 +0000 (21:47 +0000)
Lib/test/test_exception_group.py
Misc/NEWS.d/next/Core and Builtins/2022-01-24-16-58-01.bpo-46431.N6mKAx.rst [new file with mode: 0644]
Objects/exceptions.c

index f0ae37741ab60c48b03029887fb05ae41613ba84..bbfce944c17658932ed39a6eae2d5220588a8d15 100644 (file)
@@ -22,7 +22,7 @@ class TestExceptionGroupTypeHierarchy(unittest.TestCase):
 
 class BadConstructorArgs(unittest.TestCase):
     def test_bad_EG_construction__too_many_args(self):
-        MSG = 'function takes exactly 2 arguments'
+        MSG = 'BaseExceptionGroup.__new__\(\) takes exactly 2 arguments'
         with self.assertRaisesRegex(TypeError, MSG):
             ExceptionGroup('no errors')
         with self.assertRaisesRegex(TypeError, MSG):
diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-01-24-16-58-01.bpo-46431.N6mKAx.rst b/Misc/NEWS.d/next/Core and Builtins/2022-01-24-16-58-01.bpo-46431.N6mKAx.rst
new file mode 100644 (file)
index 0000000..3a2af9d
--- /dev/null
@@ -0,0 +1 @@
+Improve error message on invalid calls to :meth:`BaseExceptionGroup.__new__`.
\ No newline at end of file
index 065503f59d62d4f2c9cf33dc996f9a9b33cd1930..d8bfb31a6094aee5c814208b5ca297b785d1c296 100644 (file)
@@ -685,7 +685,10 @@ BaseExceptionGroup_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
     PyObject *message = NULL;
     PyObject *exceptions = NULL;
 
-    if (!PyArg_ParseTuple(args, "UO", &message, &exceptions)) {
+    if (!PyArg_ParseTuple(args,
+                          "UO:BaseExceptionGroup.__new__",
+                          &message,
+                          &exceptions)) {
         return NULL;
     }