This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Rework the Python threading initialization
AcceptedPublic

Authored by teemperor on Jun 16 2021, 6:19 AM.

Details

Summary

Python 3.11 will remove the functions that initialize the threading support: https://docs.python.org/3.9/c-api/init.html#c.PyEval_InitThreads

The threading support init work is done automatically as part of Py_Initialize since Python 3.7. With Python 3.9
the functions are now also no-ops and marked as deprecated to warn users[1].

This patch reworks the current initialization code so that it hopefully compiles and does the
right thing for all Python versions:

  • Python<3.7 we keep the old behaviour.
  • Python>3.7 we don't do any calls to the potentially deleted functions and just try to acquire the GIL to preserve the side-effect of the old implementation.

[1] We disabled deprecation warnings globally in LLDB so that's why we didn't see this yet.

Diff Detail

Event Timeline

teemperor requested review of this revision.Jun 16 2021, 6:19 AM
teemperor created this revision.

Looks reasonable

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

I would add return here to make it clearly evident that the function doesn't do anything more in this case.

This revision is now accepted and ready to land.Jun 16 2021, 6:40 AM