diff --git a/pytests/src/pyclasses.rs b/pytests/src/pyclasses.rs index f7e4681af70..e499b436395 100644 --- a/pytests/src/pyclasses.rs +++ b/pytests/src/pyclasses.rs @@ -66,9 +66,11 @@ impl AssertingBaseClass { #[pyclass] struct ClassWithoutConstructor; +#[cfg(any(Py_3_10, not(Py_LIMITED_API)))] #[pyclass(dict)] struct ClassWithDict; +#[cfg(any(Py_3_10, not(Py_LIMITED_API)))] #[pymethods] impl ClassWithDict { #[new] @@ -83,6 +85,7 @@ pub fn pyclasses(m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_class::()?; m.add_class::()?; m.add_class::()?; + #[cfg(any(Py_3_10, not(Py_LIMITED_API)))] m.add_class::()?; Ok(()) diff --git a/pytests/tests/test_pyclasses.py b/pytests/tests/test_pyclasses.py index e91e75fa58a..a1424fc75aa 100644 --- a/pytests/tests/test_pyclasses.py +++ b/pytests/tests/test_pyclasses.py @@ -89,7 +89,12 @@ def test_no_constructor_defined_propagates_cause(cls: Type): def test_dict(): - d = pyclasses.ClassWithDict() + try: + ClassWithDict = pyclasses.ClassWithDict + except AttributeError: + pytest.skip("not defined using abi3 < 3.9") + + d = ClassWithDict() assert d.__dict__ == {} d.foo = 42