Skip to content

fix: re-raise existing exception when available#667

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

fix: re-raise existing exception when available#667
methane merged 2 commits intomsgpack:mainfrom
KowalskiThomas:kowalski/fix-re-raise-existing-exception-when-available

Conversation

@KowalskiThomas
Copy link
Copy Markdown
Contributor

@KowalskiThomas KowalskiThomas commented Apr 21, 2026

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
Copy link
Copy Markdown
Member

methane commented Apr 21, 2026

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
Copy link
Copy Markdown
Contributor Author

KowalskiThomas commented Apr 21, 2026

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants