◐ Shell
clean mode source ↗

fix: check `unpack_callback_uint32` result by KowalskiThomas · Pull Request #666 · msgpack/msgpack-python

What does this PR do?

Similar to #665, just a return value check to propagate the error in case one happens (instead of silently ignoring it).

Note that as opposed to the previous lines, we don't need to PyErr_SetString since unpack_callback_uint32 calls PyLong_FromSize_t which itself should set whatever Python error is relevant; we just need to make it clear to the caller that an error occurred.

Note looking at the usages of the function (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,)) -- I don't know if that's expected? Shouldn't it juse raise to raise the existing exception set by PyErr_SetString or whichever? Seems like something that should probably handled in a different PR/issue, but figured I'd raise it.