Skip to content

fix: re-raise existing exception when available - #667

Merged
methane merged 2 commits into
msgpack:mainfrom
KowalskiThomas:kowalski/fix-re-raise-existing-exception-when-available
Apr 21, 2026
Merged

methane merged 2 commits into
msgpack:mainfrom
KowalskiThomas:kowalski/fix-re-raise-existing-exception-when-available

Conversation

@KowalskiThomas

@KowalskiThomas KowalskiThomas commented Apr 21, 2026 •

Copy link
Copy Markdown
Contributor

What is this PR?

This PR addresses an issue I found while working on #666 and reported in the description there.

Looking at the usages of unpack_callback_uint32 (here for example, which calls into this) it seems like it checks for error values -2 and -3, but -1 will just raise ValueError("Unpack failed: error = %d" % (ret,)).

It believe it should just raise to raise the existing exception set by PyErr_SetString if it exists. This PR addresses that problem here and another place.

@methane

methane commented Apr 21, 2026

Copy link
Copy Markdown
Member

Would it be easy to add a test case for this issue?

@KowalskiThomas

Copy link
Copy Markdown
Contributor Author

Ah yeah good point, let me have a look :)

@KowalskiThomas

KowalskiThomas commented Apr 21, 2026 •

Copy link
Copy Markdown
Contributor Author

I added a test case, but I don't think it's possible to easily cover/simulate something that would happen like in #666. But the tests do flex the PyErr_Occurred path.

@methane
methane merged commit 5d465bd into msgpack:main Apr 21, 2026
26 checks passed
@KowalskiThomas
KowalskiThomas deleted the kowalski/fix-re-raise-existing-exception-when-available branch April 29, 2026 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants