[Lldb-commits] [lldb] [lldb] Workaround omission of PyBUF_READ in the stable API (PR #152214)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Tue Aug 5 15:25:16 PDT 2025
https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/152214
PyMemoryView_FromMemory is part of stable ABI but the flag constants such as PyBUF_READ are not. This was fixed in Python 3.11 [1] but work around the issue with older versions.
[1] https://github.com/python/cpython/issues/98680
>From 38169fc7d907ee6719eeb2ab633b49a21bea4fe8 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Tue, 5 Aug 2025 15:23:57 -0700
Subject: [PATCH] [lldb] Workaround omission of PyBUF_READ in the stable API
PyMemoryView_FromMemory is part of stable ABI but the flag constants
such as PyBUF_READ are not. This was fixed in Python 3.11 [1] but work
around the issue with older versions.
[1] https://github.com/python/cpython/issues/98680
---
lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h b/lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h
index 9b4a1dd2cecb2..0c281793613a5 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h
@@ -60,6 +60,12 @@ static llvm::Expected<bool> *g_fcxx_modules_workaround [[maybe_unused]];
// with a version of Python we don't support.
static_assert(PY_VERSION_HEX >= LLDB_MINIMUM_PYTHON_VERSION,
"LLDB requires at least Python 3.8");
+
+// PyMemoryView_FromMemory is part of stable ABI but the flag constants are not.
+// See https://github.com/python/cpython/issues/98680
+#ifndef PyBUF_READ
+#define PyBUF_READ 0x100
+#endif
#endif
#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_LLDB_PYTHON_H
More information about the lldb-commits
mailing list