File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -444,21 +444,19 @@ class cpp_function : public function {
444
444
size_t args_copied = 0 ;
445
445
446
446
// 1. Copy any position arguments given.
447
+ bool bad_kwarg = false ;
447
448
for (; args_copied < args_to_copy; ++args_copied) {
448
- // If we find a given positional argument that also has a named kwargs argument,
449
- // raise a TypeError like Python does. (We could also continue with the next
450
- // overload, but this seems highly likely to be a caller mistake rather than a
451
- // legitimate overload).
452
- if (kwargs_in && args_copied < func.args .size () && func.args [args_copied].name ) {
453
- handle value = PyDict_GetItemString (kwargs_in, func.args [args_copied].name );
454
- if (value)
455
- throw type_error (std::string (func.name ) + " (): got multiple values for argument '" +
456
- std::string (func.args [args_copied].name ) + " '" );
449
+ if (kwargs_in && args_copied < func.args .size () && func.args [args_copied].name
450
+ && PyDict_GetItemString (kwargs_in, func.args [args_copied].name )) {
451
+ bad_kwarg = true ;
452
+ break ;
457
453
}
458
454
459
455
call.args .push_back (PyTuple_GET_ITEM (args_in, args_copied));
460
456
call.args_convert .push_back (args_copied < func.args .size () ? func.args [args_copied].convert : true );
461
457
}
458
+ if (bad_kwarg)
459
+ continue ; // Maybe it was meant for another overload (issue #688)
462
460
463
461
// We'll need to copy this if we steal some kwargs for defaults
464
462
dict kwargs = reinterpret_borrow<dict>(kwargs_in);
You can’t perform that action at this time.
0 commit comments