Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion msgspec/_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -6038,7 +6038,7 @@ Struct_vectorcall(PyTypeObject *cls, PyObject *const *args, size_t nargsf, PyObj
}

/* Unknown keyword */
PyErr_SetString(PyExc_TypeError, "Extra keyword arguments provided");
PyErr_Format(PyExc_TypeError, "Unexpected keyword argument '%U'", kwname);
goto error;

kw_found:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ class Test(Struct):
with pytest.raises(TypeError, match="Argument 'a' given by name and position"):
Test(1, 2, a=3)

with pytest.raises(TypeError, match="Extra keyword arguments provided"):
with pytest.raises(TypeError, match="Unexpected keyword argument 'e'"):
Test(1, 2, e=5)

def test_init_kw_only(self):
Expand All @@ -441,7 +441,7 @@ class Test(Struct, kw_only=True):
with pytest.raises(TypeError, match="Extra positional arguments provided"):
Test(1)

with pytest.raises(TypeError, match="Extra keyword arguments provided"):
with pytest.raises(TypeError, match="Unexpected keyword argument 'e'"):
Test(a=1, e=5)

def test_init_kw_only_mixed(self):
Expand All @@ -468,7 +468,7 @@ class Test(Base):
with pytest.raises(TypeError, match="Extra positional arguments provided"):
Test(1, 5.0, 3)

with pytest.raises(TypeError, match="Extra keyword arguments provided"):
with pytest.raises(TypeError, match="Unexpected keyword argument 'e'"):
Test(1, e=5)


Expand Down