From b62b65a95f2b5e79e90f3f957e7a52ec50c5fe31 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Thu, 14 Aug 2025 13:47:48 -0500 Subject: [lldb] Use (only) PyImport_AppendInittab to patch readline (#153329) The current implementation tries to (1) patch the existing readline module definition if it's already present in the inittab and (2) append our patched readline module to the inittab. The former (1) uses the non-stable Python API and I can't find a situation where this is necessary. We do this work before initialization, so for the readline module to exist, it either needs to be added by Python itself (which doesn't seem to be the case), or someone would have had to have added it without initializing. --- .../ScriptInterpreter/Python/ScriptInterpreterPython.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp') diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp index 15ea5e99..9330a63 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -98,17 +98,7 @@ public: #ifdef LLDB_USE_LIBEDIT_READLINE_COMPAT_MODULE // Python's readline is incompatible with libedit being linked into lldb. // Provide a patched version local to the embedded interpreter. - bool ReadlinePatched = false; - for (auto *p = PyImport_Inittab; p->name != nullptr; p++) { - if (strcmp(p->name, "readline") == 0) { - p->initfunc = initlldb_readline; - break; - } - } - if (!ReadlinePatched) { - PyImport_AppendInittab("readline", initlldb_readline); - ReadlinePatched = true; - } + PyImport_AppendInittab("readline", initlldb_readline); #endif // Register _lldb as a built-in module. -- cgit v1.1