From 64cb699e8ae8d8c31984d9654f1de0f5e8618e4a Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Mon, 26 Dec 2016 13:12:10 +0100 Subject: [PATCH] disable dynamic attribute test on pypy --- include/pybind11/pybind11.h | 5 +++++ tests/test_methods_and_attributes.cpp | 2 ++ tests/test_methods_and_attributes.py | 2 ++ tests/test_pickling.cpp | 2 ++ 4 files changed, 11 insertions(+) diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index 9caf35e1..5835446c 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -785,6 +785,11 @@ protected: /* Support dynamic attributes */ if (rec->dynamic_attr) { + #if defined(PYPY_VERSION) + pybind11_fail(std::string(rec->name) + ": dynamic attributes are " + "currently not supported in " + "conunction with PyPy!"); + #endif type->ht_type.tp_flags |= Py_TPFLAGS_HAVE_GC; type->ht_type.tp_dictoffset = type->ht_type.tp_basicsize; // place the dict at the end type->ht_type.tp_basicsize += sizeof(PyObject *); // and allocate enough space for it diff --git a/tests/test_methods_and_attributes.cpp b/tests/test_methods_and_attributes.cpp index 824e7431..f7d6d685 100644 --- a/tests/test_methods_and_attributes.cpp +++ b/tests/test_methods_and_attributes.cpp @@ -176,9 +176,11 @@ test_initializer methods_and_attributes([](py::module &m) { .def_property_readonly("rvalue", &TestPropRVP::get_rvalue) .def_property_readonly_static("static_rvalue", [](py::object) { return SimpleValue(); }); +#if !defined(PYPY_VERSION) py::class_(m, "DynamicClass", py::dynamic_attr()) .def(py::init()); py::class_(m, "CppDerivedDynamicClass") .def(py::init()); +#endif }); diff --git a/tests/test_methods_and_attributes.py b/tests/test_methods_and_attributes.py index 1502f77f..840ee707 100644 --- a/tests/test_methods_and_attributes.py +++ b/tests/test_methods_and_attributes.py @@ -180,6 +180,8 @@ def test_dynamic_attributes(): assert cstats.alive() == 0 +# https://bitbucket.org/pypy/pypy/issues/2447 +@pytest.unsupported_on_pypy def test_cyclic_gc(): from pybind11_tests import DynamicClass diff --git a/tests/test_pickling.cpp b/tests/test_pickling.cpp index 3941dc59..87c623d3 100644 --- a/tests/test_pickling.cpp +++ b/tests/test_pickling.cpp @@ -57,6 +57,7 @@ test_initializer pickling([](py::module &m) { p.setExtra2(t[2].cast()); }); +#if !defined(PYPY_VERSION) py::class_(m, "PickleableWithDict", py::dynamic_attr()) .def(py::init()) .def_readwrite("value", &PickleableWithDict::value) @@ -78,4 +79,5 @@ test_initializer pickling([](py::module &m) { /* Assign Python state */ self.attr("__dict__") = t[2]; }); +#endif });