[Bug python/34485] New: [gdb/python] gdbpy_initialize_gdb_readline misses error handling
"vries at gcc dot gnu.org via Gdb-prs" <[email protected]>
| Newsgroups | gmane.comp.gdb.bugs.discuss |
|---|---|
| Message-ID | <[email protected]/bugzilla/> |
https://sourceware.org/bugzilla/show_bug.cgi?id=34485
Bug ID: 34485
Summary: [gdb/python] gdbpy_initialize_gdb_readline misses
error handling
Product: gdb
Version: HEAD
Status: NEW
Severity: normal
Priority: P2
Component: python
Assignee: unassigned at sourceware dot org
Reporter: vries at gcc dot gnu.org
Target Milestone: ---
On Fedora Rawhide aarch64-linux, I ran into:
...
builtin_spawn /data/vries/gdb/build/gdb/testsuite/../../gdb/gdb -nw -nx -q -iex
set height 0 -iex set width 0 -data-directory
/data/vries/gdb/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.
/data/vries/gdb/build/gdb/testsuite/../../gdb/gdb: warning:
Could not load the Python gdb module from
`/data/vries/gdb/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 /data/vries/gdb/binutils-gdb.git/gdb/testsuite/gdb.python
Source directories searched:
/data/vries/gdb/binutils-gdb.git/gdb/testsuite/gdb.python:$cdir:$cwd
(gdb) python print (1)
1
(gdb) FAIL: gdb.python/py-failed-init.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 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
...
So the test-case needs updating, but that's not what this PR is about.
I decided to investigate where the ModuleNotFoundError is triggered, and I
found it originates from gdbpy_initialize_gdb_readline, where we do:
...
if (eval_python_command (code, Py_file_input) == 0)
PyOS_ReadlineFunctionPointer = gdbpy_readline_wrapper;
...
but don't report and reset the python error state, so instead the error is
reported by Py_Finalize.
Also, it might not be a bad idea to declare the python interactive prompt
unsupported unless PyOS_ReadlineFunctionPointer == gdbpy_readline_wrapper.
--
You are receiving this mail because:
You are on the CC list for the bug.