[binutils-gdb] [gdb/testsuite] Fix gdb.python/py-failed-init.exp with python 3.15

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=09a7362522ef0447210042a4f0309559edae82bb

commit 09a7362522ef0447210042a4f0309559edae82bb
Author: Tom de Vries <[email protected]>
Date:   Wed Aug 19 08:20:50 2026 +0200

    [gdb/testsuite] Fix gdb.python/py-failed-init.exp with python 3.15
    
    On Fedora Rawhide aarch64-linux, I ran into:
    ...
    builtin_spawn $build/gdb/gdb -nw -nx -q -iex set height 0 -iex set width 0 \
      -data-directory $build/gdb/data-directory -iex set interactive-mode on
    WARN: Could not find the standard library directory! The Python 'home'
    directory was set to 'foo', is this correct?
    Error occurred computing Python error message.
    $build/gdb/gdb: warning:
    Could not load the Python gdb module from
    `$build/gdb/data-directory/python'.
    Limited Python support is available from the _gdb module.
    Suggest passing --data-directory=/path/to/gdb/data-directory.
    (gdb) set height 0
    (gdb) set width 0
    (gdb) dir
    Reinitialize source path to empty? (y or n) y
    Source directories searched: $cdir:$cwd
    (gdb) dir $src/gdb/testsuite/gdb.python
    Source directories searched:
    $src/gdb/testsuite/gdb.python:$cdir:$cwd
    (gdb) python print (1)
    1
    (gdb) FAIL: $exp: gdb-command<python print (1)>
    quit
    Exception ignored on threading shutdown:
    Traceback (most recent call last):
      File "<string>", line 2, in <module>
    ModuleNotFoundError: No module named 'importlib'
    PASS: gdb.python/py-failed-init.exp: quit
    ...
    
    The ModuleNotFoundError reported after quit originates from
    gdbpy_initialize_gdb_readline.  I've filed a PR about this [1].
    
    The test-case tries to break python:
    ...
    save_vars { env(PYTHONHOME) } {
        setenv PYTHONHOME foo
        clean_restart
    }
    ...
    enough to get it to this point:
    ...
    gdb_test "python print (1)" \
        "Python not initialized"
    ...
    but apparently, that doesn't work anymore in this python version:
    ...
    $ python --version
    Python 3.15.0b4
    ...
    
    Update the test-case by simply accepting the output.
    
    [1] https://sourceware.org/bugzilla/show_bug.cgi?id=34485

Diff:
---
 gdb/testsuite/gdb.python/py-failed-init.exp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.python/py-failed-init.exp b/gdb/testsuite/gdb.python/py-failed-init.exp
index c2b9c990e29..b2ea8c152fe 100644
--- a/gdb/testsuite/gdb.python/py-failed-init.exp
+++ b/gdb/testsuite/gdb.python/py-failed-init.exp
@@ -22,7 +22,7 @@ save_vars { env(PYTHONHOME) } {
 }
 
 gdb_test "python print (1)" \
-    "Python not initialized"
+    "(Python not initialized|1)"
 
 set output_seen 0
 gdb_test_multiple "quit" "" {
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.