Skip to content

Commit e9bdfa2

Browse files
committed
Remove pypy-specific hacks from pybind11 patch
1 parent a932862 commit e9bdfa2

File tree

1 file changed

+1
-103
lines changed

1 file changed

+1
-103
lines changed

graalpython/lib-graalpython/patches/pybind11/pybind11-2.10.1.patch

Lines changed: 1 addition & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,3 @@
1-
diff --git a/pybind11/include/pybind11/cast.h b/pybind11/include/pybind11/cast.h
2-
index 6f0a75a..173a3d9 100644
3-
--- a/pybind11/include/pybind11/cast.h
4-
+++ b/pybind11/include/pybind11/cast.h
5-
@@ -132,7 +132,7 @@ public:
6-
return false;
7-
}
8-
9-
-#if !defined(PYPY_VERSION)
10-
+#if !defined(PYPY_VERSION) && !defined(GRAALVM_PYTHON)
11-
auto index_check = [](PyObject *o) { return PyIndex_Check(o); };
12-
#else
13-
// In PyPy 7.3.3, `PyIndex_Check` is implemented by calling `__index__`,
14-
@@ -328,7 +328,7 @@ public:
15-
if (src.is_none()) {
16-
res = 0; // None is implicitly converted to False
17-
}
18-
-#if defined(PYPY_VERSION)
19-
+#if defined(PYPY_VERSION) || defined(GRAALVM_PYTHON)
20-
// On PyPy, check that "__bool__" attr exists
21-
else if (hasattr(src, PYBIND11_BOOL_ATTR)) {
22-
res = PyObject_IsTrue(src.ptr());
23-
@@ -445,7 +445,7 @@ struct string_caster {
24-
25-
private:
26-
static handle decode_utfN(const char *buffer, ssize_t nbytes) {
27-
-#if !defined(PYPY_VERSION)
28-
+#if !defined(PYPY_VERSION) && !defined(GRAALVM_PYTHON)
29-
return UTF_N == 8 ? PyUnicode_DecodeUTF8(buffer, nbytes, nullptr)
30-
: UTF_N == 16 ? PyUnicode_DecodeUTF16(buffer, nbytes, nullptr, nullptr)
31-
: PyUnicode_DecodeUTF32(buffer, nbytes, nullptr, nullptr);
32-
diff --git a/pybind11/include/pybind11/detail/class.h b/pybind11/include/pybind11/detail/class.h
33-
index 528e716..352f686 100644
34-
--- a/pybind11/include/pybind11/detail/class.h
35-
+++ b/pybind11/include/pybind11/detail/class.h
36-
@@ -26,7 +26,7 @@ PYBIND11_NAMESPACE_BEGIN(detail)
37-
#endif
38-
39-
inline std::string get_fully_qualified_tp_name(PyTypeObject *type) {
40-
-#if !defined(PYPY_VERSION)
41-
+#if !defined(PYPY_VERSION) && !defined(GRAALVM_PYTHON)
42-
return type->tp_name;
43-
#else
44-
auto module_name = handle((PyObject *) type).attr("__module__").cast<std::string>();
45-
@@ -42,7 +42,7 @@ inline PyTypeObject *type_incref(PyTypeObject *type) {
46-
return type;
47-
}
48-
49-
-#if !defined(PYPY_VERSION)
50-
+#if !defined(PYPY_VERSION) && !defined(GRAALVM_PYTHON)
51-
52-
/// `pybind11_static_property.__get__()`: Always pass the class instead of the instance.
53-
extern "C" inline PyObject *pybind11_static_get(PyObject *self, PyObject * /*ob*/, PyObject *cls) {
54-
@@ -149,7 +149,7 @@ extern "C" inline int pybind11_meta_setattro(PyObject *obj, PyObject *name, PyOb
55-
&& (PyObject_IsInstance(value, static_prop) == 0);
56-
if (call_descr_set) {
57-
// Call `static_property.__set__()` instead of replacing the `static_property`.
58-
-#if !defined(PYPY_VERSION)
59-
+#if !defined(PYPY_VERSION) && !defined(GRAALVM_PYTHON)
60-
return Py_TYPE(descr)->tp_descr_set(descr, obj, value);
61-
#else
62-
if (PyObject *result = PyObject_CallMethod(descr, "__set__", "OO", obj, value)) {
63-
@@ -347,7 +347,7 @@ inline bool deregister_instance(instance *self, void *valptr, const type_info *t
64-
/// for holding C++ objects and holders. Allocation is done lazily (the first time the instance is
65-
/// cast to a reference or pointer), and initialization is done by an `__init__` function.
66-
inline PyObject *make_new_instance(PyTypeObject *type) {
67-
-#if defined(PYPY_VERSION)
68-
+#if defined(PYPY_VERSION) || defined(GRAALVM_PYTHON)
69-
// PyPy gets tp_basicsize wrong (issue 2482) under multiple inheritance when the first
70-
// inherited object is a plain Python type (i.e. not derived from an extension type). Fix it.
71-
ssize_t instance_size = static_cast<ssize_t>(sizeof(instance));
72-
@@ -638,7 +638,7 @@ inline PyObject *make_new_python_type(const type_record &rec) {
73-
}
74-
75-
const auto *full_name = c_str(
76-
-#if !defined(PYPY_VERSION)
77-
+#if !defined(PYPY_VERSION) && !defined(GRAALVM_PYTHON)
78-
module_ ? str(module_).cast<std::string>() + "." + rec.name :
79-
#endif
80-
rec.name);
811
diff --git a/pybind11/include/pybind11/detail/common.h b/pybind11/include/pybind11/detail/common.h
822
index f34fd27..f1681b7 100644
833
--- a/pybind11/include/pybind11/detail/common.h
@@ -214,7 +134,7 @@ index 42d432a..2e12a93 100644
214134
PyFrameObject *frame = PyThreadState_GetFrame(PyThreadState_Get());
215135
if (frame != nullptr) {
216136
diff --git a/pybind11/include/pybind11/pytypes.h b/pybind11/include/pybind11/pytypes.h
217-
index d21fc89..70cf72a 100644
137+
index d21fc89..8e12dbb 100644
218138
--- a/pybind11/include/pybind11/pytypes.h
219139
+++ b/pybind11/include/pybind11/pytypes.h
220140
@@ -534,7 +534,7 @@ struct error_fetch_and_normalize {
@@ -226,25 +146,3 @@ index d21fc89..70cf72a 100644
226146
auto *tb = reinterpret_cast<PyTracebackObject *>(m_trace.ptr());
227147

228148
// Get the deepest trace possible.
229-
@@ -1208,7 +1208,7 @@ private:
230-
};
231-
PYBIND11_NAMESPACE_END(iterator_policies)
232-
233-
-#if !defined(PYPY_VERSION)
234-
+#if !defined(PYPY_VERSION) && !defined(GRAALVM_PYTHON)
235-
using tuple_iterator = generic_iterator<iterator_policies::sequence_fast_readonly>;
236-
using list_iterator = generic_iterator<iterator_policies::sequence_fast_readonly>;
237-
#else
238-
diff --git a/pybind11/include/pybind11/stl/filesystem.h b/pybind11/include/pybind11/stl/filesystem.h
239-
index e26f421..a221955 100644
240-
--- a/pybind11/include/pybind11/stl/filesystem.h
241-
+++ b/pybind11/include/pybind11/stl/filesystem.h
242-
@@ -40,7 +40,7 @@ struct path_caster {
243-
244-
private:
245-
static PyObject *unicode_from_fs_native(const std::string &w) {
246-
-# if !defined(PYPY_VERSION)
247-
+# if !defined(PYPY_VERSION) && !defined(GRAALVM_PYTHON)
248-
return PyUnicode_DecodeFSDefaultAndSize(w.c_str(), ssize_t(w.size()));
249-
# else
250-
// PyPy mistakenly declares the first parameter as non-const.

0 commit comments

Comments
 (0)