Skip to content

Conversation

@JDevlieghere
Copy link
Member

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] python/cpython#98680

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] python/cpython#98680
@llvmbot
Copy link
Member

llvmbot commented Aug 5, 2025

@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)

Changes

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] python/cpython#98680


Full diff: https://github.com/llvm/llvm-project/pull/152214.diff

1 Files Affected:

  • (modified) lldb/source/Plugins/ScriptInterpreter/Python/lldb-python.h (+6)
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

@JDevlieghere JDevlieghere merged commit 7b8dea2 into llvm:main Aug 6, 2025
11 checks passed
@JDevlieghere JDevlieghere deleted the PyBUF_READ branch August 6, 2025 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants