@@ -2740,11 +2740,15 @@ _PyArg_CheckPositional(const char *name, Py_ssize_t nargs,
2740
2740
assert (min <= max );
2741
2741
2742
2742
if (nargs < min ) {
2743
- if (name != NULL )
2743
+ if (name != NULL ) {
2744
+ // Use "positional argument" for dict functions, "argument" for others
2745
+ const char * arg_type = (strcmp (name , "dict" ) == 0 || strcmp (name , "update" ) == 0 )
2746
+ ? "positional argument" : "argument" ;
2744
2747
PyErr_Format (
2745
2748
PyExc_TypeError ,
2746
- "%.200s expected %s%zd argument%s, got %zd" ,
2747
- name , (min == max ? "" : "at least " ), min , min == 1 ? "" : "s" , nargs );
2749
+ "%.200s expected %s%zd %s%s, got %zd" ,
2750
+ name , (min == max ? "" : "at least " ), min , arg_type , min == 1 ? "" : "s" , nargs );
2751
+ }
2748
2752
else
2749
2753
PyErr_Format (
2750
2754
PyExc_TypeError ,
@@ -2759,11 +2763,15 @@ _PyArg_CheckPositional(const char *name, Py_ssize_t nargs,
2759
2763
}
2760
2764
2761
2765
if (nargs > max ) {
2762
- if (name != NULL )
2766
+ if (name != NULL ) {
2767
+ // Use "positional argument" for dict functions, "argument" for others
2768
+ const char * arg_type = (strcmp (name , "dict" ) == 0 || strcmp (name , "update" ) == 0 )
2769
+ ? "positional argument" : "argument" ;
2763
2770
PyErr_Format (
2764
2771
PyExc_TypeError ,
2765
- "%.200s expected %s%zd argument%s, got %zd" ,
2766
- name , (min == max ? "" : "at most " ), max , max == 1 ? "" : "s" , nargs );
2772
+ "%.200s expected %s%zd %s%s, got %zd" ,
2773
+ name , (min == max ? "" : "at most " ), max , arg_type , max == 1 ? "" : "s" , nargs );
2774
+ }
2767
2775
else
2768
2776
PyErr_Format (
2769
2777
PyExc_TypeError ,
0 commit comments