For a gdb build with python 2, I run 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: __repr__ returned non-string (type instance)\n"^M ^error,msg="Error occurred in Python: __repr__ returned non-string (type instance)"^M (gdb) ^M ...
Using a standalone reproducer: ... $ cat test.py class BadKey: def __repr__(self): return "Bad Key" class ReallyBadKey: def __repr__(self): return BadKey() a = {"result": {ReallyBadKey(): "world"}} print (a) ... we can see the behaviour with python3: ... $ python3 test.py Traceback (most recent call last): File "test.py", line 12, in <module> print (a) TypeError: __repr__ returned non-string (type BadKey) ... and python2: ... $ python2 test.py {'result': {Traceback (most recent call last): File "test.py", line 12, in <module> print (a) TypeError: __repr__ returned non-string (type instance) ...
This fixes it: ... diff --git a/gdb/testsuite/gdb.python/py-mi-cmd.exp b/gdb/testsuite/gdb.python/py-mi-cmd.ex p index 300ab956892..5e4b6cd076e 100644 --- a/gdb/testsuite/gdb.python/py-mi-cmd.exp +++ b/gdb/testsuite/gdb.python/py-mi-cmd.exp @@ -68,8 +68,8 @@ mi_gdb_test "-pycmd bk2" \ 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 \\)\""] \ + "&\"TypeError: __repr__ returned non-string \\(type (BadKey|instance)\\)..\"" \ + "\\^error,msg=\"Error occurred in Python: __repr__ returned non-string \\(type (B adKey|instance)\\)\""] \ "-pycmd bk3" mi_gdb_test "-pycmd tpl" \ ... I don't see a pressing need to fix this on the gdb-12-branch, so I'm closing this as resolved-wontfix. Anybody running into this with gdb 12.x and finding it annoying can use the patch posted in this comment.