From 50ede76876981364d6b1a314bb79c0412980c435 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Sat, 9 Mar 2024 16:13:10 +0100 Subject: [gdb/python] Normalize exceptions in gdbpy_err_fetch With python 3.12, I run into: ... (gdb) PASS: gdb.python/py-block.exp: check variable access python print (block['nonexistent'])^M Python Exception : 'nonexistent'^M Error occurred in Python: 'nonexistent'^M (gdb) FAIL: gdb.python/py-block.exp: check nonexistent variable ... The problem is that that PyErr_Fetch returns a normalized exception, while the test-case matches the output for an unnormalized exception. With python 3.6, PyErr_Fetch returns an unnormalized exception, and the test passes. Fix this by: - updating the test-case to match the output for a normalized exception, and - lazily forcing normalized exceptions using PyErr_NormalizeException. Tested on aarch64-linux. Approved-By: Tom Tromey --- gdb/testsuite/gdb.python/py-block.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gdb/testsuite/gdb.python') diff --git a/gdb/testsuite/gdb.python/py-block.exp b/gdb/testsuite/gdb.python/py-block.exp index 942611a..99642a5 100644 --- a/gdb/testsuite/gdb.python/py-block.exp +++ b/gdb/testsuite/gdb.python/py-block.exp @@ -44,7 +44,7 @@ gdb_test "python print (block.function)" "None" "first anonymous block" gdb_test "python print (block.start)" "${decimal}" "check start not None" gdb_test "python print (block.end)" "${decimal}" "check end not None" gdb_test "python print (block\['f'\].name == 'f')" "True" "check variable access" -gdb_test "python print (block\['nonexistent'\])" ".*KeyError.*: nonexistent.*" \ +gdb_test "python print (block\['nonexistent'\])" ".*KeyError.*: 'nonexistent'.*" \ "check nonexistent variable" gdb_test "python print (block\[42\])" ".*TypeError.*: Expected a string.*" \ "check non-string key" -- cgit v1.1