Skip to content

Commit 1411207

Browse files
chore: drop support for PyPy < 7.3.1 and clean up old PyPy workarounds (#2456)
* Remove code inside 'PYPY_VERSION_NUM < 0x06000000' preprocessor if branch * fix: more cleanup * Remove more references to PyPy 5.7 and 5.9 in the docs * Update comment on PyUnicode_UTF* in PyPy Co-authored-by: Henry Schreiner <[email protected]>
1 parent b70894d commit 1411207

File tree

6 files changed

+8
-16
lines changed

6 files changed

+8
-16
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Goodies
6868
In addition to the core functionality, pybind11 provides some extra
6969
goodies:
7070

71-
- Python 2.7, 3.5+, and PyPy (tested on 7.3) are supported with an
71+
- Python 2.7, 3.5+, and PyPy/PyPy3 7.3 are supported with an
7272
implementation-agnostic interface.
7373

7474
- It is possible to bind C++11 lambda functions with captured

docs/advanced/misc.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ avoids this issue involves weak reference with a cleanup callback:
223223

224224
.. code-block:: cpp
225225
226-
// Register a callback function that is invoked when the BaseClass object is colelcted
226+
// Register a callback function that is invoked when the BaseClass object is collected
227227
py::cpp_function cleanup_callback(
228228
[](py::handle weakref) {
229229
// perform cleanup here -- this function is called with the GIL held
@@ -237,9 +237,9 @@ avoids this issue involves weak reference with a cleanup callback:
237237
238238
.. note::
239239

240-
PyPy (at least version 5.9) does not garbage collect objects when the
241-
interpreter exits. An alternative approach (which also works on CPython) is to use
242-
the :py:mod:`atexit` module [#f7]_, for example:
240+
PyPy does not garbage collect objects when the interpreter exits. An alternative
241+
approach (which also works on CPython) is to use the :py:mod:`atexit` module [#f7]_,
242+
for example:
243243

244244
.. code-block:: cpp
245245

include/pybind11/cast.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,10 +1277,8 @@ template <typename StringType, bool IsView = false> struct string_caster {
12771277
UTF_N == 16 ? PyUnicode_DecodeUTF16(buffer, nbytes, nullptr, nullptr) :
12781278
PyUnicode_DecodeUTF32(buffer, nbytes, nullptr, nullptr);
12791279
#else
1280-
// PyPy seems to have multiple problems related to PyUnicode_UTF*: the UTF8 version
1281-
// sometimes segfaults for unknown reasons, while the UTF16 and 32 versions require a
1282-
// non-const char * arguments, which is also a nuisance, so bypass the whole thing by just
1283-
// passing the encoding as a string value, which works properly:
1280+
// PyPy segfaults when on PyUnicode_DecodeUTF16 (and possibly on PyUnicode_DecodeUTF32 as well),
1281+
// so bypass the whole thing by just passing the encoding as a string value, which works properly:
12841282
return PyUnicode_Decode(buffer, nbytes, UTF_N == 8 ? "utf-8" : UTF_N == 16 ? "utf-16" : "utf-32", nullptr);
12851283
#endif
12861284
}

include/pybind11/detail/class.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -478,10 +478,6 @@ extern "C" inline int pybind11_clear(PyObject *self) {
478478
/// Give instances of this type a `__dict__` and opt into garbage collection.
479479
inline void enable_dynamic_attributes(PyHeapTypeObject *heap_type) {
480480
auto type = &heap_type->ht_type;
481-
#if defined(PYPY_VERSION) && (PYPY_VERSION_NUM < 0x06000000)
482-
pybind11_fail(get_fully_qualified_tp_name(type) + ": dynamic attributes are currently not "
483-
"supported in conjunction with PyPy!");
484-
#endif
485481
type->tp_flags |= Py_TPFLAGS_HAVE_GC;
486482
type->tp_dictoffset = type->tp_basicsize; // place dict at the end
487483
type->tp_basicsize += (ssize_t)sizeof(PyObject *); // and allocate enough space for it

include/pybind11/eval.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void exec(const char (&s)[N], object global = globals(), object local = object()
6666
eval<eval_statements>(s, global, local);
6767
}
6868

69-
#if defined(PYPY_VERSION) && PY_VERSION_HEX >= 0x3000000
69+
#if defined(PYPY_VERSION) && PY_VERSION_HEX >= 0x03000000
7070
template <eval_mode mode = eval_statements>
7171
object eval_file(str, object, object) {
7272
pybind11_fail("eval_file not supported in PyPy3. Use eval");

tests/test_multiple_inheritance.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,12 @@ TEST_SUBMODULE(multiple_inheritance, m) {
193193
.def_readwrite_static("static_value", &VanillaStaticMix2::static_value);
194194

195195

196-
#if !(defined(PYPY_VERSION) && (PYPY_VERSION_NUM < 0x06000000))
197196
struct WithDict { };
198197
struct VanillaDictMix1 : Vanilla, WithDict { };
199198
struct VanillaDictMix2 : WithDict, Vanilla { };
200199
py::class_<WithDict>(m, "WithDict", py::dynamic_attr()).def(py::init<>());
201200
py::class_<VanillaDictMix1, Vanilla, WithDict>(m, "VanillaDictMix1").def(py::init<>());
202201
py::class_<VanillaDictMix2, WithDict, Vanilla>(m, "VanillaDictMix2").def(py::init<>());
203-
#endif
204202

205203
// test_diamond_inheritance
206204
// Issue #959: segfault when constructing diamond inheritance instance

0 commit comments

Comments
 (0)