-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[lldb] Limit Py_buffer_RAII to SWIG < 4.1 #167808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lldb] Limit Py_buffer_RAII to SWIG < 4.1 #167808
Conversation
|
@llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) ChangesThe bug [1] this is working around was fixed in SWIG 4.1. The workaround uses functions and constants that are not part of the limited API, which I'm trying to eliminate to make LLDB compatible with the Python Limited C API [2]. [1] swig/swig#1640 Full diff: https://github.com/llvm/llvm-project/pull/167808.diff 2 Files Affected:
diff --git a/lldb/bindings/python/python-typemaps.h b/lldb/bindings/python/python-typemaps.h
index 8a533e822988e..366ae5e6a6676 100644
--- a/lldb/bindings/python/python-typemaps.h
+++ b/lldb/bindings/python/python-typemaps.h
@@ -3,6 +3,7 @@
#include <Python.h>
+#if SWIG_VERSION < 0x040100
// Defined here instead of a .swig file because SWIG 2 doesn't support
// explicit deleted functions.
struct Py_buffer_RAII {
@@ -15,5 +16,6 @@ struct Py_buffer_RAII {
PyBuffer_Release(&buffer);
}
};
+#endif
#endif // LLDB_BINDINGS_PYTHON_PYTHON_TYPEMAPS_H
diff --git a/lldb/bindings/python/python-typemaps.swig b/lldb/bindings/python/python-typemaps.swig
index 4d3a95768f2f3..2064ac3c892f6 100644
--- a/lldb/bindings/python/python-typemaps.swig
+++ b/lldb/bindings/python/python-typemaps.swig
@@ -637,9 +637,7 @@ template <> bool SetNumberFromPyObject<double>(double &number, PyObject *obj) {
// These two pybuffer macros are copied out of swig/Lib/python/pybuffer.i,
// and fixed so they will not crash if PyObject_GetBuffer fails.
// https://github.com/swig/swig/issues/1640
-//
-// I've also moved the call to PyBuffer_Release to the end of the SWIG wrapper,
-// doing it right away is not legal according to the python buffer protocol.
+#if SWIG_VERSION < 0x040100
%define %pybuffer_mutable_binary(TYPEMAP, SIZE)
%typemap(in) (TYPEMAP, SIZE) (Py_buffer_RAII view) {
@@ -678,6 +676,8 @@ template <> bool SetNumberFromPyObject<double>(double &number, PyObject *obj) {
%pybuffer_binary(const uint8_t *buf, size_t num_bytes);
%pybuffer_mutable_binary(uint8_t *buf, size_t num_bytes);
+#endif
+
%typemap(in) (const char **symbol_name, uint32_t num_names) {
using namespace lldb_private;
/* Check if is a list */
|
The bug [1] this is working around was fixed in SWIG 4.1. The workaround uses functions and constants that are not part of the limited API, which I'm trying to eliminate to make LLDB compatible with the Python Limited C API [2]. [1] swig/swig#1640 [2] llvm#151617
5baef17 to
169d7d8
Compare
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/162/builds/35160 Here is the relevant piece of the build log for the reference |
|
According to the build bot page, the Debian bot is using |
|
Ugh, okay, this is going to be a problem... SWIG is using the "Old Buffer Protocol" when targeting the limited API: https://github.com/swig/swig/blob/master/Lib/python/pybuffer.i. However these were removed in Python 3.13... |
This reverts commit ac2d3d1.
|
Seems like SWIG is aware of the problem: swig/swig@05c439d |
The bug [1] this is working around was fixed in SWIG 4.1. The workaround uses functions and constants that are not part of the limited API, which I'm trying to eliminate to make LLDB compatible with the Python Limited C API [2].
[1] swig/swig#1640
[2] #151617