aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2024-02-17 15:10:09 -0800
committerGitHub <noreply@github.com>2024-02-17 15:10:09 -0800
commitfbce244299524fc3d736cce9d25b4262303b45d5 (patch)
tree20139d1af99359b352a14facfb1f52f4828f718d /lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
parenta6df3472feeb618513877ec136db38f4746142fb (diff)
downloadllvm-fbce244299524fc3d736cce9d25b4262303b45d5.zip
llvm-fbce244299524fc3d736cce9d25b4262303b45d5.tar.gz
llvm-fbce244299524fc3d736cce9d25b4262303b45d5.tar.bz2
[lldb] Call Import_AppendInittab before Py_Initialize (#82095)
The Python documentation [1] says that `PyImport_AppendInittab` should be called before `Py_Initialize()`. Starting with Python 3.12, this is enforced with a fatal error: Fatal Python error: PyImport_AppendInittab: PyImport_AppendInittab() may not be called after Py_Initialize() This commit ensures we only modify the table of built-in modules if Python hasn't been initialized. For Python embedded in LLDB, that means this happen exactly once, before the first call to `Py_Initialize`, which becomes a NO-OP after. However, when lldb is imported in an existing Python interpreter, Python will have already been initialized, but by definition, the lldb module will already have been loaded, so it's safe to skip adding it (again). This fixes #70453. [1] https://docs.python.org/3.12/c-api/import.html#c.PyImport_AppendInittab
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h')
0 files changed, 0 insertions, 0 deletions