Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Lib/test/clinic.test.c
Original file line number Diff line number Diff line change
Expand Up @@ -4968,7 +4968,7 @@ Test___init__(PyObject *self, PyObject *args, PyObject *kwargs)

if ((Py_IS_TYPE(self, base_tp) ||
Py_TYPE(self)->tp_new == base_tp->tp_new) &&
!_PyArg_NoPositional("Test", args)) {
!_PyArg_NoPositionalStack("Test", PyTuple_GET_SIZE(args))) {
goto exit;
}
if ((Py_IS_TYPE(self, base_tp) ||
Expand Down Expand Up @@ -5017,7 +5017,7 @@ Test_vectorcall(PyObject *type, PyObject *const *args,

static int
Test___init___impl(TestObj *self)
/*[clinic end generated code: output=ce04b9d7beacd894 input=645fe693f6c6b9b6]*/
/*[clinic end generated code: output=62017ea6333c9634 input=645fe693f6c6b9b6]*/


/*[clinic input]
Expand All @@ -5042,11 +5042,11 @@ Test(PyTypeObject *type, PyObject *args, PyObject *kwargs)
PyTypeObject *base_tp = TestType;

if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
!_PyArg_NoPositional("Test", args)) {
!_PyArg_NoPositionalStack(_PyType_Name(_PyType_CAST(type)), PyTuple_GET_SIZE(args))) {
goto exit;
}
if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
!_PyArg_NoKeywords("Test", kwargs)) {
!_PyArg_NoKeywords(_PyType_Name(_PyType_CAST(type)), kwargs)) {
goto exit;
}
return_value = Test_impl(type);
Expand All @@ -5057,7 +5057,7 @@ Test(PyTypeObject *type, PyObject *args, PyObject *kwargs)

static PyObject *
Test_impl(PyTypeObject *type)
/*[clinic end generated code: output=68a117adc057940f input=6fe98a19f097907f]*/
/*[clinic end generated code: output=deab914e0af675ba input=6fe98a19f097907f]*/


/*[clinic input]
Expand Down Expand Up @@ -5248,7 +5248,7 @@ Test(PyTypeObject *type, PyObject *args, PyObject *kwargs)
PyObject *__clinic_args = NULL;

if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
!_PyArg_NoKeywords("Test", kwargs)) {
!_PyArg_NoKeywords(_PyType_Name(_PyType_CAST(type)), kwargs)) {
goto exit;
}
__clinic_args = Py_NewRef(args);
Expand All @@ -5263,7 +5263,7 @@ Test(PyTypeObject *type, PyObject *args, PyObject *kwargs)

static PyObject *
Test_impl(PyTypeObject *type, PyObject *args)
/*[clinic end generated code: output=e6fba0c8951882fd input=8ce30adb836aeacb]*/
/*[clinic end generated code: output=9e97b89fb3f12f76 input=8ce30adb836aeacb]*/


/*[clinic input]
Expand Down
11 changes: 11 additions & 0 deletions Lib/test/test_clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5806,6 +5806,17 @@ def test_vc_new_base_subclass(self):
self.assertIsInstance(obj, Sub)
self.assertIsInstance(obj, ac_tester.VcNewBase)

def test_new_errors_name_subclass(self):
# tp_new is inherited, so its errors name the subclass; the
# vectorcall only sees the base type.
Sub = type('Sub', (float,), {})
with self.assertRaisesRegex(TypeError, r'^float expected at most 1'):
float(1, 2)
with self.assertRaisesRegex(TypeError, r'^Sub expected at most 1'):
Sub(1, 2)
with self.assertRaisesRegex(TypeError, r'^Sub\(\) takes no keyword'):
Sub(x=1)

def test_vc_kwonly(self):
# keyword-only 'b': vectorcall has no kwnames==NULL fast path,
# so every call goes through the helper.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Generate subclass names in Argument Clinic ``__new__`` error messages rather
than hardcoding the base type.
6 changes: 3 additions & 3 deletions Modules/_sqlite/clinic/row.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Modules/clinic/_bz2module.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Modules/clinic/_collectionsmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Modules/clinic/_csv.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Modules/clinic/_queuemodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Modules/clinic/_ssl.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Modules/clinic/_testclinic_kwds.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Modules/clinic/_threadmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Modules/clinic/_zoneinfo.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading