Created on 2005-09-06 19:12 by japierro, last changed 2009-04-05 14:31 by georg.brandl. This issue is now closed.
|msg26218 - (view)||Author: japierro (japierro)||Date: 2005-09-06 19:12|
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
|msg26219 - (view)||Author: Georg Brandl (georg.brandl) *||Date: 2005-12-16 19:43|
Logged In: YES user_id=1188172 Any opinions?
|msg26220 - (view)||Author: Martin v. Löwis (loewis) *||Date: 2005-12-27 13:48|
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.
|msg83876 - (view)||Author: Daniel Diniz (ajaksu2)||Date: 2009-03-20 22:31|
Fixed on trunk and py3k, can someone test on the release branches? Python 2.7a0 (trunk, Feb 24 2009, 10:30:17) >>> re.compile("a").match(pos=10) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: Required argument 'pattern' (pos 1) not found
|msg85501 - (view)||Author: Georg Brandl (georg.brandl) *||Date: 2009-04-05 14:31|
Looks like the new message is in 2.6 as well.
|2009-04-05 14:31:48||georg.brandl||set||status: open -> closed|
nosy: + georg.brandl
messages: + msg85501
messages: + msg83876
versions: + Python 2.6, Python 3.0