Skip to content

Commit b62b65a

Browse files
authored
[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.
1 parent 20a8299 commit b62b65a

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,7 @@ struct InitializePythonRAII {
9898
#ifdef LLDB_USE_LIBEDIT_READLINE_COMPAT_MODULE
9999
// Python's readline is incompatible with libedit being linked into lldb.
100100
// Provide a patched version local to the embedded interpreter.
101-
bool ReadlinePatched = false;
102-
for (auto *p = PyImport_Inittab; p->name != nullptr; p++) {
103-
if (strcmp(p->name, "readline") == 0) {
104-
p->initfunc = initlldb_readline;
105-
break;
106-
}
107-
}
108-
if (!ReadlinePatched) {
109-
PyImport_AppendInittab("readline", initlldb_readline);
110-
ReadlinePatched = true;
111-
}
101+
PyImport_AppendInittab("readline", initlldb_readline);
112102
#endif
113103

114104
// Register _lldb as a built-in module.

0 commit comments

Comments
 (0)