aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2025-08-14 13:47:48 -0500
committerGitHub <noreply@github.com>2025-08-14 13:47:48 -0500
commitb62b65a95f2b5e79e90f3f957e7a52ec50c5fe31 (patch)
treedba148a84d6afee353cffb7de447b7bedabee841 /lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
parent20a829937cc8cd69170b75c0bb7f31ad9ba19677 (diff)
downloadllvm-b62b65a95f2b5e79e90f3f957e7a52ec50c5fe31.zip
llvm-b62b65a95f2b5e79e90f3f957e7a52ec50c5fe31.tar.gz
llvm-b62b65a95f2b5e79e90f3f957e7a52ec50c5fe31.tar.bz2
[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.
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp')
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp12
1 files changed, 1 insertions, 11 deletions
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.