mirror of https://github.com/python/cpython
bpo-46431: improve error message on invalid calls to BaseExceptionGroup.__new__ (GH-30854)
This commit is contained in:
parent
1c705fda8f
commit
573b545157
|
@ -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):
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Improve error message on invalid calls to :meth:`BaseExceptionGroup.__new__`.
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue