binutils-gdb/gdb/python
Matthieu Longo 7cb9d3f078 py-gdb-readline: replace deprecated interfaces in GdbRemoveReadlineFinder
A previous patch [1] enabled readline in Python in a GDB-specific way
and blocked the standard Python readline module to prevent conflicts
with GDB by adding a custom importer raising an exception for the readline
module.

This custom importer was written back in 2012 for old Python versions,
and does not seem to work anymore with Python 3.x. find_module() and
load_module() have been deprecated since Python 3.4, and the first one
has been removed since 3.12, and the second will be removed in 3.15.
The GDB testsuite does not cover this use case, and the removal of
find_module() was not detected by the testsuite. This issue is tracked
in bug 32473.

importlib.abc.MetaPathFinder:
  find_module(fullname, path)
    Deprecated since version 3.4: Use find_spec() instead.
    Changed in version 3.10: Use of find_module() by the import
    system now raises ImportWarning.
    Changed in version 3.12: find_module() has been removed. Use
    find_spec() instead.

  find_spec(fullname, path, target=None)
    New in version 3.4, as a replacement for find_module.

importlib.abc.Loader:
  load_module(fullname):
    Deprecated since version 3.4, will be removed in version 3.15
    The recommended API for loading a module is exec_module()
    (and create_module()).

This patch uses Patryk Sondej's approach detailed in bug 32473, but with
a slight variation regarding the finder insertion in sys.meta_path.
It also adds a new test to prevent future regression.

[1]: 037bbc8eea

Approved-By: Tom Tromey <tom@tromey.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32473
2026-01-14 11:01:40 +00:00
..
lib/gdb Show constants in DAP scopes output 2026-01-09 08:37:27 -07:00
py-all-events.def Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-arch.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-auto-load.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-block.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-bpevent.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-breakpoint.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-cmd.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-color.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-color.h Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-connection.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-continueevent.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-corefile.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-dap.c Small cleanup to interpreter initialization 2026-01-06 10:12:55 -07:00
py-disasm.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-event-types.def Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-event.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-event.h Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-events.h Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-evtregistry.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-evts.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-exitedevent.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-finishbreakpoint.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-frame.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-framefilter.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-function.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-gdb-readline.c py-gdb-readline: replace deprecated interfaces in GdbRemoveReadlineFinder 2026-01-14 11:01:40 +00:00
py-inferior.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-infevents.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-infthread.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-instruction.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-instruction.h Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-lazy-string.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-linetable.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-membuf.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-mi.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-micmd.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-newobjfileevent.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-objfile.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-param.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-prettyprint.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-progspace.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-record-btrace.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-record-btrace.h Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-record-full.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-record-full.h Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-record.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-record.h Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-ref.h Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-registers.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-signalevent.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-stopevent.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-stopevent.h Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-style.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-symbol.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-symtab.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-threadevent.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-tui.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-type.c gdb: remove make_cv_type typeptr parameter 2026-01-06 14:59:15 -05:00
py-uiout.h Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-unwind.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-utils.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-value.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-varobj.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-xmethods.c gdb: remove make_cv_type typeptr parameter 2026-01-06 14:59:15 -05:00
python-config.py Run isort 2024-04-02 11:21:39 -06:00
python-internal.h Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
python.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
python.h Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00