[Python-checkins] bpo-46431: improve error message on invalid calls to BaseExceptionGroup.__new__ (GH-30854)
iritkatriel
webhook-mailer at python.org
Mon Jan 24 16:48:00 EST 2022
https://github.com/python/cpython/commit/573b54515740ce51dcf2402038a9d953aa6c317f
commit: 573b54515740ce51dcf2402038a9d953aa6c317f
branch: main
author: Irit Katriel <1055913+iritkatriel at users.noreply.github.com>
committer: iritkatriel <1055913+iritkatriel at users.noreply.github.com>
date: 2022-01-24T21:47:40Z
summary:
bpo-46431: improve error message on invalid calls to BaseExceptionGroup.__new__ (GH-30854)
files:
A Misc/NEWS.d/next/Core and Builtins/2022-01-24-16-58-01.bpo-46431.N6mKAx.rst
M Lib/test/test_exception_group.py
M Objects/exceptions.c
diff --git a/Lib/test/test_exception_group.py b/Lib/test/test_exception_group.py
index f0ae37741ab60..bbfce944c1765 100644
--- a/Lib/test/test_exception_group.py
+++ b/Lib/test/test_exception_group.py
@@ -22,7 +22,7 @@ def test_exception_group_is_generic_type(self):
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
index 0000000000000..3a2af9df03c38
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2022-01-24-16-58-01.bpo-46431.N6mKAx.rst
@@ -0,0 +1 @@
+Improve error message on invalid calls to :meth:`BaseExceptionGroup.__new__`.
\ No newline at end of file
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index 065503f59d62d..d8bfb31a6094a 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -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;
}
More information about the Python-checkins
mailing list