From bf507da154f18f47609f6511b86750c7d5e975e5 Mon Sep 17 00:00:00 2001 From: David Hewitt <1939362+davidhewitt@users.noreply.github.com> Date: Tue, 7 Jan 2020 09:01:35 +0000 Subject: [PATCH 1/2] Remove specialization from FromPyObject blanket impls --- CHANGELOG.md | 4 ++++ src/conversion.rs | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7e8315c68b..3d568d1dcf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## Unreleased +### Changed + +* The blanket implementations for `FromPyObject` for `&T` and `&mut T` are no longer specializable. Implement `PyTryFrom` for your type to control the behavior of `FromPyObject::extract()` for your types. + ## [0.8.5] * Support for `#[name = "foo"]` attribute for `#[pyfunction]` and in `#[pymethods]`. [#692](https://github.com/PyO3/pyo3/pull/692) diff --git a/src/conversion.rs b/src/conversion.rs index 38f436de496..2c2243aa6a4 100644 --- a/src/conversion.rs +++ b/src/conversion.rs @@ -250,7 +250,7 @@ where T: PyTryFrom<'a>, { #[inline] - default fn extract(ob: &'a PyAny) -> PyResult<&'a T> { + fn extract(ob: &'a PyAny) -> PyResult<&'a T> { Ok(T::try_from(ob)?) } } @@ -261,7 +261,7 @@ where T: PyTryFrom<'a>, { #[inline] - default fn extract(ob: &'a PyAny) -> PyResult<&'a mut T> { + fn extract(ob: &'a PyAny) -> PyResult<&'a mut T> { Ok(T::try_from_mut(ob)?) } } From 72e9abd4c7a1bd88bf927d47180e9a51b2bdc50c Mon Sep 17 00:00:00 2001 From: David Hewitt <1939362+davidhewitt@users.noreply.github.com> Date: Tue, 7 Jan 2020 09:32:34 +0000 Subject: [PATCH 2/2] Remove specialization from IntoPy implementation --- CHANGELOG.md | 1 + src/conversion.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d568d1dcf3..bd8c315ba0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed * The blanket implementations for `FromPyObject` for `&T` and `&mut T` are no longer specializable. Implement `PyTryFrom` for your type to control the behavior of `FromPyObject::extract()` for your types. +* The implementation for `IntoPy for T` where `U: FromPy` is no longer specializable. Control the behavior of this via the implementation of `FromPy`. ## [0.8.5] diff --git a/src/conversion.rs b/src/conversion.rs index 2c2243aa6a4..45c3a389331 100644 --- a/src/conversion.rs +++ b/src/conversion.rs @@ -146,7 +146,7 @@ impl IntoPy for T where U: FromPy, { - default fn into_py(self, py: Python) -> U { + fn into_py(self, py: Python) -> U { U::from_py(self, py) } }