<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/151617>151617</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Make LLDB compatible with the Python Limited C API
</td>
</tr>
<tr>
<th>Labels</th>
<td>
metaissue,
lldb
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
JDevlieghere
</td>
</tr>
</table>
<pre>
Currently, LLDB uses the Python private or unstable API. This [means](https://lldb.llvm.org/resources/caveats.html#python) that LLDB only works with the exact same version of Python that LLDB was compiled with. See https://docs.python.org/3/c-api/stable.html for more details.
Previously, we were limited by SWIG, which generated code that wasn't part of the limited API. As of [version 4.2](https://www.swig.org/Release/CHANGES), SWIG generates code that's compatible with the Python 3.4 stable API and later.
Currently, the minimum Python version is 3.8. Based on a quick attempt to define `Py_LIMITED_API` to `0x03080000`, we'll need to find replacements for the following identifiers:
- `_Py_IsFinalizing`
- `_PyObject_Dump`
- `Py_buffer`
- `PyBUF_READ`
- `PyBUF_SIMPLE`
- `PyBytes_AS_STRING`
- `PyGILState_Check`
- `PyList_GET_SIZE`
- `PyRun_SimpleString`
- `PyRun_String`
- `PyTuple_GET_SIZE`
- `PyUnicode_AsUTF8AndSize`
This issue tracks the work to migrate over to only using the limited C API in LLDB.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx8VMGO4jgQ_RpzKXVkHBLgkEOAppcVPYs6tFbaS-QkBfG2Y2dthwzz9SsHaBrNaE5R6tnlV6-qHrdWHBViQqIFiVYj3rlam-TPFZ6kwGONBkeFrs7JsjMGlZNnwpaw3a4W0Fm04GqE3dnVWkFrxIk7BG2gU9bxQiKku00A-1pYINGiQa4siVaEzWrnWkvClLA1YWspqyKQ8tQE2hwJWxu0ujMlWsLWJT8hdzaoXSMJC9vhLcLm4GruLkS0kmfotfmw0AtXD5zwOy8dWN4gnNBYoRXow43p_WrPLZS6aYXEargcQIYIj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