aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/python.c
diff options
context:
space:
mode:
authorMatthieu Longo <matthieu.longo@arm.com>2026-01-06 13:12:38 +0000
committerMatthieu Longo <matthieu.longo@arm.com>2026-01-28 09:41:25 +0000
commit264a8a2236e8aa64b333a69e42a55ff8c0844f6e (patch)
treecf460000f0eb1644f7539760603870081fb29a5e /gdb/python/python.c
parentea96771a0188a235645558ae10d6885c91c1ac00 (diff)
downloadbinutils-264a8a2236e8aa64b333a69e42a55ff8c0844f6e.tar.gz
binutils-264a8a2236e8aa64b333a69e42a55ff8c0844f6e.tar.bz2
binutils-264a8a2236e8aa64b333a69e42a55ff8c0844f6e.zip
Python limited API: migrate Py_CompileStringExFlags and PyRun_SimpleString
This patch replaces Py_CompileStringExFlags () with its limited C API equivalent, Py_CompileString (). The eval_python_command () helper is now exposed through the private GDB Python API as a utility function. PyRun_SimpleString () is replaced with eval_python_command () to avoid code duplication. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23830 Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/python/python.c')
-rw-r--r--gdb/python/python.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 87fce272c42..989add70d1a 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -299,9 +299,9 @@ gdbpy_check_quit_flag (const struct extension_language_defn *extlang)
NULL means that this is evaluating a string, not the contents of a
file. */
-static int
+int
eval_python_command (const char *command, int start_symbol,
- const char *filename = nullptr)
+ const char *filename)
{
PyObject *m, *d;
@@ -340,13 +340,12 @@ eval_python_command (const char *command, int start_symbol,
}
}
- /* Use this API because it is in Python 3.2. */
- gdbpy_ref<> code (Py_CompileStringExFlags (command,
- filename == nullptr
- ? "<string>"
- : filename,
- start_symbol,
- nullptr, -1));
+ /* Use this API because it is available with the Python limited API. */
+ gdbpy_ref<> code (Py_CompileString (command,
+ filename == nullptr
+ ? "<string>"
+ : filename,
+ start_symbol));
int result = -1;
if (code != nullptr)