[binutils-gdb] [gdb/testsuite] Fix gdb.python/py-mi-cmd.exp

Tom de Vries via Gdb-cvs <[email protected]>
Newsgroups gmane.comp.gdb.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=bbe4c6cf3d39c3370f9a1a57fbb862d330241c27

commit bbe4c6cf3d39c3370f9a1a57fbb862d330241c27
Author: Tom de Vries <[email protected]>
Date:   Wed Aug 12 23:16:25 2026 +0200

    [gdb/testsuite] Fix gdb.python/py-mi-cmd.exp
    
    On Fedora Rawhide aarch64-linux (using Python 3.15.0b4), with test-case
    gdb.python/py-mi-cmd.exp I ran into:
    ...
    Expecting: ^(-pycmd bk3[^M
    ]+)?(&"TypeError.*: __repr__ returned non-string \(type BadKey\).."^M
    \^error,msg="Error occurred in Python: __repr__ returned non-string \(type BadKey\)"[^M
    ]+[(]gdb[)] ^M
    [ ]*)
    -pycmd bk3^M
    &"TypeError: ReallyBadKey.__repr__() must return a str, not BadKey\n"^M
    ^error,msg="Error occurred in Python: ReallyBadKey.__repr__() must return a str, not BadKey"^M
    (gdb) ^M
    FAIL: $exp: -pycmd bk3 (unexpected output)
    ...
    
    Fix this by updating the regexp.
    
    Tested with aarch64-linux (Python 3.15.0b4) and x86_64-linux (Python 3.13.14).
    
    Approved-By: Tom Tromey <[email protected]>

Diff:
---
 gdb/testsuite/gdb.python/py-mi-cmd.exp | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/gdb/testsuite/gdb.python/py-mi-cmd.exp b/gdb/testsuite/gdb.python/py-mi-cmd.exp
index b66a73c331f..3c57a7ae322 100644
--- a/gdb/testsuite/gdb.python/py-mi-cmd.exp
+++ b/gdb/testsuite/gdb.python/py-mi-cmd.exp
@@ -68,10 +68,19 @@ mi_gdb_test "-pycmd bk2" \
     "\\^error,msg=\"Error occurred in Python: non-string object used as key: 1\"" \
     "-pycmd bk2"
 
+set re_msg \
+    [string cat \
+	 "(" \
+	 [string_to_regexp {__repr__ returned non-string (type BadKey)}] \
+	 "|" \
+	 [string_to_regexp \
+	      {ReallyBadKey.__repr__() must return a str, not BadKey}] \
+	 ")"]
 mi_gdb_test "-pycmd bk3" \
-    [multi_line \
-	 "&\"TypeError.*: __repr__ returned non-string \\(type BadKey\\)..\"" \
-	 "\\^error,msg=\"Error occurred in Python: __repr__ returned non-string \\(type BadKey\\)\""] \
+    [subst_vars \
+	 [multi_line \
+	      {&"TypeError.*: $re_msg\\n"} \
+	      {\^error,msg="Error occurred in Python: $re_msg"}]] \
     "-pycmd bk3"
 
 mi_gdb_test "-pycmd tpl" \
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.