From 1cefcd551b28ed549a1bc4ba1c1c2f72c624d975 Mon Sep 17 00:00:00 2001 From: Thomas Kowalski Date: Tue, 21 Apr 2026 08:45:33 +0200 Subject: [PATCH] fix: re-raise existing exception when available --- msgpack/_unpacker.pyx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/msgpack/_unpacker.pyx b/msgpack/_unpacker.pyx index f0cf96d..e25986e 100644 --- a/msgpack/_unpacker.pyx +++ b/msgpack/_unpacker.pyx @@ -205,7 +205,10 @@ def unpackb(object packed, *, object object_hook=None, object list_hook=None, raise FormatError elif ret == -3: raise StackError - raise ValueError("Unpack failed: error = %d" % (ret,)) + elif PyErr_Occurred(): + raise + else: + raise ValueError("Unpack failed: error = %d" % (ret,)) cdef class Unpacker: @@ -481,6 +484,8 @@ cdef class Unpacker: raise FormatError elif ret == -3: raise StackError + elif PyErr_Occurred(): + raise else: raise ValueError("Unpack failed: error = %d" % (ret,))