diff options
| author | Jonas Devlieghere <jonas@devlieghere.com> | 2024-10-31 08:46:35 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-31 08:46:35 -0700 |
| commit | 9ce0a61bdbf13d4d0f2e13e1bb6e7a4bb9d01858 (patch) | |
| tree | 0348189ac2d8593b317649d3d42bba38a3f97dd4 /lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp | |
| parent | 9234ae1bbeddd66d8bed3c55c26f8eee0c827aed (diff) | |
| download | llvm-9ce0a61bdbf13d4d0f2e13e1bb6e7a4bb9d01858.zip llvm-9ce0a61bdbf13d4d0f2e13e1bb6e7a4bb9d01858.tar.gz llvm-9ce0a61bdbf13d4d0f2e13e1bb6e7a4bb9d01858.tar.bz2 | |
[lldb] Use PY_VERSION_HEX to simplify conditional compilation (NFC) (#114346)
Use PY_VERSION_HEX to simplify conditional compilation depending on the
Python version.
This also adds a static_assert to lldb-python to error out with a
meaningful diagnostic when you try building LLDB with an older Python
version in preparation for [1].
[1]
https://discourse.llvm.org/t/rfc-lets-document-and-enforce-a-minimum-python-version-for-lldb/82731/15
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp')
| -rw-r--r-- | lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp index 90ccd10..a0f8cf9 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp @@ -71,12 +71,12 @@ Expected<std::string> python::As<std::string>(Expected<PythonObject> &&obj) { } static bool python_is_finalizing() { -#if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 13) || (PY_MAJOR_VERSION > 3) +#if PY_VERSION_HEX >= 0x030d0000 return Py_IsFinalizing(); -#elif PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 7 - return _Py_Finalizing != nullptr; -#else +#elif PY_VERSION_HEX >= 0x03070000 return _Py_IsFinalizing(); +#else + return _Py_Finalizing != nullptr; #endif } @@ -810,7 +810,7 @@ bool PythonCallable::Check(PyObject *py_obj) { return PyCallable_Check(py_obj); } -#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 3 +#if PY_VERSION_HEX >= 0x03030000 static const char get_arg_info_script[] = R"( from inspect import signature, Parameter, ismethod from collections import namedtuple @@ -839,7 +839,7 @@ Expected<PythonCallable::ArgInfo> PythonCallable::GetArgInfo() const { if (!IsValid()) return nullDeref(); -#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 3 +#if PY_VERSION_HEX >= 0x03030000 // no need to synchronize access to this global, we already have the GIL static PythonScript get_arg_info(get_arg_info_script); |
