@@ -2740,11 +2740,15 @@ _PyArg_CheckPositional(const char *name, Py_ssize_t nargs,
27402740 assert (min <= max );
27412741
27422742 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" ;
27442747 PyErr_Format (
27452748 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+ }
27482752 else
27492753 PyErr_Format (
27502754 PyExc_TypeError ,
@@ -2759,11 +2763,15 @@ _PyArg_CheckPositional(const char *name, Py_ssize_t nargs,
27592763 }
27602764
27612765 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" ;
27632770 PyErr_Format (
27642771 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+ }
27672775 else
27682776 PyErr_Format (
27692777 PyExc_TypeError ,
0 commit comments