Skip to content
Open
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 @@ -22102,7 +22102,7 @@ PyInit__core(void)
st->DecodeError = PyErr_NewExceptionWithDoc(
"msgspec.DecodeError",
"An error occurred while decoding an object",
st->MsgspecError, NULL
PyTuple_Pack(2, st->MsgspecError, PyExc_ValueError), NULL
);
if (st->DecodeError == NULL)
return NULL;
Expand Down
8 changes: 8 additions & 0 deletions tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,14 @@ class Custom(metaclass=Metaclass):
with pytest.raises(TypeError, match="Oh no!"):
dec.decode(msg)

@pytest.mark.parametrize("err_cls", [msgspec.DecodeError, msgspec.ValidationError])
def test_decode_errors_subclass_of_value_error(self, err_cls):
assert issubclass(err_cls, ValueError)

@pytest.mark.parametrize("err_cls", [msgspec.EncodeError, msgspec.MsgspecError])
def test_other_errors_not_subclass_of_value_error(self, err_cls):
assert not issubclass(err_cls, ValueError)


@pytest.mark.skipif(
PY312,
Expand Down