From aabad7cf7f3acd2cd7088dc9ded34b20fa9e9ec8 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sun, 11 Oct 2020 19:51:27 -0400 Subject: [PATCH] Assorted updates to the abi3 branch from review --- Cargo.toml | 3 ++- examples/rustapi_module/tests/test_datetime.py | 2 +- guide/src/class.md | 2 +- tests/test_text_signature.rs | 4 ++-- tests/ui/abi3_nativetype_inheritance.rs | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 230bd52a..97395ac2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,8 @@ rustversion = "1.0" [features] default = ["macros"] macros = ["ctor", "indoc", "inventory", "paste", "pyo3cls", "unindent"] -# Use only limited API. See https://www.python.org/dev/peps/pep-0384/ for more. +# Use the Python limited API. See https://www.python.org/dev/peps/pep-0384/ for +# more. abi3 = [] # Optimizes PyObject to Vec conversion and so on. diff --git a/examples/rustapi_module/tests/test_datetime.py b/examples/rustapi_module/tests/test_datetime.py index e44b5090..6a820fa6 100644 --- a/examples/rustapi_module/tests/test_datetime.py +++ b/examples/rustapi_module/tests/test_datetime.py @@ -328,5 +328,5 @@ def test_tz_class_introspection(): tzi = rdt.TzClass() assert tzi.__class__ == rdt.TzClass - # PyPy generate for some reason. + # PyPy generates for some reason. assert re.match(r"^<[\w\.]*TzClass object at", repr(tzi)) diff --git a/guide/src/class.md b/guide/src/class.md index d4db1106..ecdcc76f 100644 --- a/guide/src/class.md +++ b/guide/src/class.md @@ -266,7 +266,7 @@ impl SubSubClass { ``` You can also inherit native types such as `PyDict`, if they implement -[`PySizedLayout`](https://docs.rs/pyo3/latest/pyo3/type_object/trait.PySizedLayout.html). +[`PySizedLayout`](https://docs.rs/pyo3/latest/pyo3/type_object/trait.PySizedLayout.html). However, this is not supported when building for the Python limited API (aka the `abi3` feature of PyO3). However, because of some technical problems, we don't currently provide safe upcasting methods for types that inherit native types. Even in such cases, you can unsafely get a base class by raw pointer conversion. diff --git a/tests/test_text_signature.rs b/tests/test_text_signature.rs index feca3f3e..3c9abdba 100644 --- a/tests/test_text_signature.rs +++ b/tests/test_text_signature.rs @@ -32,7 +32,7 @@ fn class_with_docs() { } #[test] -#[cfg_attr(Py_LIMITED_API, ignore)] +#[cfg_attr(all(Py_LIMITED_API, not(Py_3_10)), ignore)] fn class_with_docs_and_signature() { /// docs line1 #[pyclass] @@ -68,7 +68,7 @@ fn class_with_docs_and_signature() { } #[test] -#[cfg_attr(Py_LIMITED_API, ignore)] +#[cfg_attr(all(Py_LIMITED_API, not(Py_3_10)), ignore)] fn class_with_signature() { #[pyclass] #[text_signature = "(a, b=None, *, c=42)"] diff --git a/tests/ui/abi3_nativetype_inheritance.rs b/tests/ui/abi3_nativetype_inheritance.rs index 6816d2d5..80faff1b 100644 --- a/tests/ui/abi3_nativetype_inheritance.rs +++ b/tests/ui/abi3_nativetype_inheritance.rs @@ -1,4 +1,4 @@ -//! With abi3, we cannot inherite native types. +//! With abi3, we cannot inherit native types. use pyo3::prelude::*; use pyo3::types::PyDict;