From 584dff159efa4af6ed946725d2a7435d1e5ff4ad Mon Sep 17 00:00:00 2001 From: Tamino Bauknecht Date: Tue, 2 Jul 2024 14:10:02 +0200 Subject: [PATCH] python: Fix PythonException for Python 3.12 The explicit size check for the tuple is so that no IndexError exception is set by Python. --- src/python_exception.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_exception.cpp b/src/python_exception.cpp index 275ea53..665bf6d 100644 --- a/src/python_exception.cpp +++ b/src/python_exception.cpp @@ -23,7 +23,7 @@ std::optional 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