Bugs item #1283289, was opened at 2005-09-06 21:12 Message generated for change (Comment added) made by loewis You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1283289&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Extension Modules Group: None Status: Open Resolution: None Priority: 5 Submitted By: japierro (japierro) Assigned to: Martin v. Löwis (loewis) Summary: PyArg_ParseTupleAndKeywords gives misleading error message Initial Comment: Python 2.3.3 on Windows XP If the user supplies one valid and one invalid keyword to a function that defines two required keyword arguments, PyArg_ParseTupleAndKeywords will raise this exception: TypeError: function takes exactly 2 arguments (1 given) If, in getargs.c, vgetargskeywords, the check for "extraneous keywords" were done near the top of the function, a more meaningful exception would be thrown: TypeError: 'bad' is an invalid keyword argument for this function ---------------------------------------------------------------------- >Comment By: Martin v. Löwis (loewis) Date: 2005-12-27 14:48 Message: Logged In: YES user_id=21627 I agree that the error message should be fixed; this is even an 'XXX' comment ("an this isn't a bug?"). Unfortunately, just looking for bad keyword arguments is not enough - it might even be that an optional keyword argument is supplied, and still the error message is confusing, e.g. for >>> re.compile("a").match(pos=10) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: match() takes at least 1 argument (0 given) Instead, I think the error message should read: TypeError: "pattern" argument for match() is missing as we know exactly what "meaning" the missing argument has. This might still be unspecific if multiple required arguments are missing, but I think just giving the first one would be informative enough - or else it could read TypeError: "pattern" argument for match() is missing (+2 more) if there are 2 more missing. Yet alternatively, it could read TypeError: required arguments for match() missing: 'pattern', 'foo', 'bar' Patches in this direction are welcome; the precise wording proposal should be mentioned on python-dev. ---------------------------------------------------------------------- Comment By: Reinhold Birkenfeld (birkenfeld) Date: 2005-12-16 20:43 Message: Logged In: YES user_id=1188172 Any opinions? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1283289&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com