From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 651DF3858C74; Wed, 28 Feb 2024 11:01:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 651DF3858C74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1709118074; bh=J4/RWZwW95loemeCeEoMkVNpgvGTSmJDoMJp7k81cR8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=T6wy/t8A9pem9gEysLrKAwwzQnPwQGgEpxASKaCjlNtzWUbgoZkLUIXShe673NX8B pvp14ITeDjeSB2DYU3dLm8XQ3hZ5v2kijUMGYeB14Y7ldLhg4ZmIf6TRWG23q9xLcA K48JBrBpTFmdWd70qb7DyNAZ/JV+4m7/MtPVlVYs= From: "vries at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug python/31425] [gdb/python, 3.12] FAIL: gdb.python/py-block.exp: check nonexistent variable Date: Wed, 28 Feb 2024 11:01:14 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: python X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31425 --- Comment #5 from Tom de Vries --- The following patch avoid the deprecated PyErr_Fetch for python >=3D 3.12, = and makes the FAIL disappear: ... diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index c68aff5340e..3318f8b8c35 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -640,12 +640,31 @@ class gdbpy_err_fetch gdbpy_err_fetch () { +#if PY_VERSION_HEX < 0x030c0000 PyObject *error_type, *error_value, *error_traceback; PyErr_Fetch (&error_type, &error_value, &error_traceback); m_error_type.reset (error_type); m_error_value.reset (error_value); m_error_traceback.reset (error_traceback); +#else + PyObject *ex =3D PyErr_GetRaisedException (); + if (ex =3D=3D nullptr) + { + m_error_type.reset (nullptr); + m_error_value.reset (nullptr); + m_error_traceback.reset (nullptr); + } + else + { + m_error_traceback.reset (PyException_GetTraceback (ex)); + m_error_type.reset ((PyObject *)Py_TYPE (ex)); + Py_INCREF (m_error_type.get ()); + PyObject *args =3D PyException_GetArgs (ex); + m_error_value.reset (PyTuple_GetItem (args, 0)); + Py_INCREF (m_error_value.get ()); + } +#endif } /* Call PyErr_Restore using the values stashed in this object. ... --=20 You are receiving this mail because: You are on the CC list for the bug.=