@@ -3875,7 +3875,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag)
3875
3875
3876
3876
static void
3877
3877
format_missing (PyThreadState * tstate , const char * kind ,
3878
- PyCodeObject * co , PyObject * names )
3878
+ PyCodeObject * co , PyObject * names , PyObject * qualname )
3879
3879
{
3880
3880
int err ;
3881
3881
Py_ssize_t len = PyList_GET_SIZE (names );
@@ -3928,7 +3928,7 @@ format_missing(PyThreadState *tstate, const char *kind,
3928
3928
return ;
3929
3929
_PyErr_Format (tstate , PyExc_TypeError ,
3930
3930
"%U() missing %i required %s argument%s: %U" ,
3931
- co -> co_name ,
3931
+ qualname ,
3932
3932
len ,
3933
3933
kind ,
3934
3934
len == 1 ? "" : "s" ,
@@ -3939,7 +3939,7 @@ format_missing(PyThreadState *tstate, const char *kind,
3939
3939
static void
3940
3940
missing_arguments (PyThreadState * tstate , PyCodeObject * co ,
3941
3941
Py_ssize_t missing , Py_ssize_t defcount ,
3942
- PyObject * * fastlocals )
3942
+ PyObject * * fastlocals , PyObject * qualname )
3943
3943
{
3944
3944
Py_ssize_t i , j = 0 ;
3945
3945
Py_ssize_t start , end ;
@@ -3971,14 +3971,14 @@ missing_arguments(PyThreadState *tstate, PyCodeObject *co,
3971
3971
}
3972
3972
}
3973
3973
assert (j == missing );
3974
- format_missing (tstate , kind , co , missing_names );
3974
+ format_missing (tstate , kind , co , missing_names , qualname );
3975
3975
Py_DECREF (missing_names );
3976
3976
}
3977
3977
3978
3978
static void
3979
3979
too_many_positional (PyThreadState * tstate , PyCodeObject * co ,
3980
3980
Py_ssize_t given , Py_ssize_t defcount ,
3981
- PyObject * * fastlocals )
3981
+ PyObject * * fastlocals , PyObject * qualname )
3982
3982
{
3983
3983
int plural ;
3984
3984
Py_ssize_t kwonly_given = 0 ;
@@ -4022,7 +4022,7 @@ too_many_positional(PyThreadState *tstate, PyCodeObject *co,
4022
4022
}
4023
4023
_PyErr_Format (tstate , PyExc_TypeError ,
4024
4024
"%U() takes %U positional argument%s but %zd%U %s given" ,
4025
- co -> co_name ,
4025
+ qualname ,
4026
4026
sig ,
4027
4027
plural ? "s" : "" ,
4028
4028
given ,
@@ -4034,7 +4034,8 @@ too_many_positional(PyThreadState *tstate, PyCodeObject *co,
4034
4034
4035
4035
static int
4036
4036
positional_only_passed_as_keyword (PyThreadState * tstate , PyCodeObject * co ,
4037
- Py_ssize_t kwcount , PyObject * const * kwnames )
4037
+ Py_ssize_t kwcount , PyObject * const * kwnames ,
4038
+ PyObject * qualname )
4038
4039
{
4039
4040
int posonly_conflicts = 0 ;
4040
4041
PyObject * posonly_names = PyList_New (0 );
@@ -4079,7 +4080,7 @@ positional_only_passed_as_keyword(PyThreadState *tstate, PyCodeObject *co,
4079
4080
_PyErr_Format (tstate , PyExc_TypeError ,
4080
4081
"%U() got some positional-only arguments passed"
4081
4082
" as keyword arguments: '%U'" ,
4082
- co -> co_name , error_names );
4083
+ qualname , error_names );
4083
4084
Py_DECREF (error_names );
4084
4085
goto fail ;
4085
4086
}
@@ -4180,7 +4181,7 @@ _PyEval_EvalCode(PyThreadState *tstate,
4180
4181
if (keyword == NULL || !PyUnicode_Check (keyword )) {
4181
4182
_PyErr_Format (tstate , PyExc_TypeError ,
4182
4183
"%U() keywords must be strings" ,
4183
- co -> co_name );
4184
+ qualname );
4184
4185
goto fail ;
4185
4186
}
4186
4187
@@ -4211,14 +4212,14 @@ _PyEval_EvalCode(PyThreadState *tstate,
4211
4212
4212
4213
if (co -> co_posonlyargcount
4213
4214
&& positional_only_passed_as_keyword (tstate , co ,
4214
- kwcount , kwnames ))
4215
+ kwcount , kwnames , qualname ))
4215
4216
{
4216
4217
goto fail ;
4217
4218
}
4218
4219
4219
4220
_PyErr_Format (tstate , PyExc_TypeError ,
4220
4221
"%U() got an unexpected keyword argument '%S'" ,
4221
- co -> co_name , keyword );
4222
+ qualname , keyword );
4222
4223
goto fail ;
4223
4224
}
4224
4225
@@ -4231,7 +4232,7 @@ _PyEval_EvalCode(PyThreadState *tstate,
4231
4232
if (GETLOCAL (j ) != NULL ) {
4232
4233
_PyErr_Format (tstate , PyExc_TypeError ,
4233
4234
"%U() got multiple values for argument '%S'" ,
4234
- co -> co_name , keyword );
4235
+ qualname , keyword );
4235
4236
goto fail ;
4236
4237
}
4237
4238
Py_INCREF (value );
@@ -4240,7 +4241,7 @@ _PyEval_EvalCode(PyThreadState *tstate,
4240
4241
4241
4242
/* Check the number of positional arguments */
4242
4243
if ((argcount > co -> co_argcount ) && !(co -> co_flags & CO_VARARGS )) {
4243
- too_many_positional (tstate , co , argcount , defcount , fastlocals );
4244
+ too_many_positional (tstate , co , argcount , defcount , fastlocals , qualname );
4244
4245
goto fail ;
4245
4246
}
4246
4247
@@ -4254,7 +4255,7 @@ _PyEval_EvalCode(PyThreadState *tstate,
4254
4255
}
4255
4256
}
4256
4257
if (missing ) {
4257
- missing_arguments (tstate , co , missing , defcount , fastlocals );
4258
+ missing_arguments (tstate , co , missing , defcount , fastlocals , qualname );
4258
4259
goto fail ;
4259
4260
}
4260
4261
if (n > m )
@@ -4292,7 +4293,7 @@ _PyEval_EvalCode(PyThreadState *tstate,
4292
4293
missing ++ ;
4293
4294
}
4294
4295
if (missing ) {
4295
- missing_arguments (tstate , co , missing , -1 , fastlocals );
4296
+ missing_arguments (tstate , co , missing , -1 , fastlocals , qualname );
4296
4297
goto fail ;
4297
4298
}
4298
4299
}
0 commit comments