This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients ncoghlan
Date 2017-09-20.05:17:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1505884677.44.0.281868370705.issue31527@psf.upfronthosting.co.za>
In-reply-to
Content
object_new and object_init currently use their own argument checking logic, and hence haven't benefited from the error reporting enhancements in PyArg_ParseTupleAndKeywords

Compare:

>>> str(1, 2, 3, 4, 5, x=1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: str() takes at most 3 arguments (6 given)
>>> str(x=1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'x' is an invalid keyword argument for this function

To:

>>> C(1, 2, 3, 4)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: object() takes no parameters
>>> C(x=1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: object() takes no parameters

Issue 31506 amends the latter to at least report the subclass name rather than the base class name, but doesn't cover any other enhancements, like reporting how many arguments were actually given, or the first unknown keyword argument name.
History
Date User Action Args
2017-09-20 05:17:57ncoghlansetrecipients: + ncoghlan
2017-09-20 05:17:57ncoghlansetmessageid: <1505884677.44.0.281868370705.issue31527@psf.upfronthosting.co.za>
2017-09-20 05:17:57ncoghlanlinkissue31527 messages
2017-09-20 05:17:57ncoghlancreate