diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2022-01-24 17:18:18 -0800 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2022-01-24 17:23:09 -0800 |
commit | 16bff06790a7652b282352b07250b627e5787c8c (patch) | |
tree | 7c4899c8cb4755f0cd72f225614ab54f21a3915f /lldb/source/Plugins/ScriptInterpreter/Python | |
parent | 8b29b84c99ac8140c9820fd34b733bdedf5bb0f5 (diff) | |
download | llvm-16bff06790a7652b282352b07250b627e5787c8c.zip llvm-16bff06790a7652b282352b07250b627e5787c8c.tar.gz llvm-16bff06790a7652b282352b07250b627e5787c8c.tar.bz2 |
[lldb] Make PythonDataObjects work with Python 2
I considered keeping this change strictly downstream. Since we still
have a bunch of places that check for Python 2, I figured it doesn't
harm to land it upstream and avoid the conflict when I eventually do
remove them (hopefully soon!).
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python')
-rw-r--r-- | lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp index 32020f9..68f4e90 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp @@ -70,7 +70,9 @@ Expected<std::string> python::As<std::string>(Expected<PythonObject> &&obj) { } static bool python_is_finalizing() { -#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 7 +#if PY_MAJOR_VERSION == 2 + return false; +#elif PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 7 return _Py_Finalizing != nullptr; #else return _Py_IsFinalizing(); @@ -279,7 +281,9 @@ PythonObject PythonObject::GetAttributeValue(llvm::StringRef attr) const { } StructuredData::ObjectSP PythonObject::CreateStructuredObject() const { +#if PY_MAJOR_VERSION >= 3 assert(PyGILState_Check()); +#endif switch (GetObjectType()) { case PyObjectType::Dictionary: return PythonDictionary(PyRefType::Borrowed, m_py_obj) |