Skip to content

Commit

Permalink
python: Fix PythonException for Python 3.12
Browse files Browse the repository at this point in the history
The explicit size check for the tuple is so that no IndexError exception
is set by Python.
  • Loading branch information
taminob committed Jul 2, 2024
1 parent dfa7791 commit 584dff1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/python_exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ std::optional<PythonException> PythonException::latest()
PythonObject exception { PyErr_GetRaisedException() };
PythonObject type { PyObject_Type(exception.pyObject()) };
PythonObject args_tuple { PyException_GetArgs(exception.pyObject()) };
PythonObject value { (PyTuple_Size(args_tuple.pyObject()) > 0) ? args_tuple
PythonObject value { (PyTuple_Size(args_tuple.pyObject()) > 0) ? PyTuple_GetItem(args_tuple.pyObject(), 0)
: nullptr };
PythonObject traceback { PyException_GetTraceback(exception.pyObject()) };
#else
Expand Down

0 comments on commit 584dff1

Please sign in to comment.