pyproto: deprecate protocol traits

This commit is contained in:
David Hewitt 2022-02-17 06:53:10 +00:00
parent d8ee35e19c
commit 24445df633
17 changed files with 25 additions and 1 deletions

View File

@ -72,7 +72,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `PyDate_FromTimestamp`
- Deprecate the `gc` option for `pyclass` (e.g. `#[pyclass(gc)]`). Just implement a `__traverse__` `#[pymethod]`. [#2159](https://github.com/PyO3/pyo3/pull/2159)
- The `ml_meth` field of `PyMethodDef` is now represented by the `PyMethodDefPointer` union [2166](https://github.com/PyO3/pyo3/pull/2166)
- The `PyTypeError` thrown when argument parsing failed now contains the nested causes [2177](https://github.com/PyO3/pyo3/pull/2178)
- Deprecate the `#[pyproto]` traits. [#2173](https://github.com/PyO3/pyo3/pull/2173)
### Removed
@ -91,6 +91,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add missing FFI definitions `_PyLong_NumBits` and `_PyLong_AsByteArray` on PyPy. [#2146](https://github.com/PyO3/pyo3/pull/2146)
- Fix memory leak in implementation of `AsPyPointer` for `Option<T>`. [#2160](https://github.com/PyO3/pyo3/pull/2160)
- Fix the signature of `_PyLong_NumBits` [#2161](https://github.com/PyO3/pyo3/pull/2161)
- Fix `TypeError` thrown when argument parsing failed missing the originating causes. [2177](https://github.com/PyO3/pyo3/pull/2178)
## [0.15.1] - 2021-11-19

View File

@ -1,3 +1,4 @@
#![allow(deprecated)]
// Copyright (c) 2017-present PyO3 Project and Contributors
//! Basic Python Object customization
@ -14,6 +15,7 @@ use std::os::raw::c_int;
/// Basic Python class customization
#[allow(unused_variables)]
#[deprecated(since = "0.16.0", note = "prefer `#[pymethods]` to `#[pyproto]`")]
pub trait PyObjectProtocol<'p>: PyClass {
fn __getattr__(&'p self, name: Self::Name) -> Self::Result
where

View File

@ -1,3 +1,4 @@
#![allow(deprecated)]
// Copyright (c) 2017-present PyO3 Project and Contributors
//! Represent Python Buffer protocol implementation
@ -13,6 +14,7 @@ use std::os::raw::c_int;
/// For more information check [buffer protocol](https://docs.python.org/3/c-api/buffer.html)
/// c-api.
#[allow(unused_variables)]
#[deprecated(since = "0.16.0", note = "prefer `#[pymethods]` to `#[pyproto]`")]
pub trait PyBufferProtocol<'p>: PyClass {
// No default implementations so that implementors of this trait provide both methods.

View File

@ -1,3 +1,4 @@
#![allow(deprecated)]
// Copyright (c) 2017-present PyO3 Project and Contributors
//! Python Description Interface
@ -11,6 +12,7 @@ use std::os::raw::c_int;
/// Descriptor interface
#[allow(unused_variables)]
#[deprecated(since = "0.16.0", note = "prefer `#[pymethods]` to `#[pyproto]`")]
pub trait PyDescrProtocol<'p>: PyClass {
fn __get__(
slf: Self::Receiver,

View File

@ -1,3 +1,4 @@
#![allow(deprecated)]
// Copyright (c) 2017-present PyO3 Project and Contributors
//! Python GC support
@ -9,6 +10,7 @@ use std::os::raw::{c_int, c_void};
pub struct PyTraverseError(c_int);
/// GC support
#[deprecated(since = "0.16.0", note = "prefer `#[pymethods]` to `#[pyproto]`")]
pub trait PyGCProtocol<'p>: PyClass {
fn __traverse__(&'p self, visit: PyVisit) -> Result<(), PyTraverseError>;
fn __clear__(&'p mut self);

View File

@ -1,3 +1,4 @@
#![allow(deprecated)]
// Copyright (c) 2017-present PyO3 Project and Contributors
//! Python Iterator Interface.
//! Trait and support implementation for implementing iterators
@ -43,6 +44,7 @@ use crate::{PyClass, PyObject};
/// # }); // test of StopIteration is done in pytests/src/pyclasses.rs
/// ```
#[allow(unused_variables)]
#[deprecated(since = "0.16.0", note = "prefer `#[pymethods]` to `#[pyproto]`")]
pub trait PyIterProtocol<'p>: PyClass {
fn __iter__(slf: Self::Receiver) -> Self::Result
where

View File

@ -1,3 +1,4 @@
#![allow(deprecated)]
// Copyright (c) 2017-present PyO3 Project and Contributors
//! Python Mapping Interface
@ -8,6 +9,7 @@ use crate::{FromPyObject, PyClass, PyObject};
/// Mapping interface
#[allow(unused_variables)]
#[deprecated(since = "0.16.0", note = "prefer `#[pymethods]` to `#[pyproto]`")]
pub trait PyMappingProtocol<'p>: PyClass {
fn __len__(&'p self) -> Self::Result
where

View File

View File

@ -1,3 +1,4 @@
#![allow(deprecated)]
// Copyright (c) 2017-present PyO3 Project and Contributors
//! Python object protocols

View File

@ -1,3 +1,4 @@
#![allow(deprecated)]
// Copyright (c) 2017-present PyO3 Project and Contributors
//! Python Number Interface
@ -8,6 +9,7 @@ use crate::{ffi, FromPyObject, PyClass, PyObject};
/// Number interface
#[allow(unused_variables)]
#[deprecated(since = "0.16.0", note = "prefer `#[pymethods]` to `#[pyproto]`")]
pub trait PyNumberProtocol<'p>: PyClass {
fn __add__(lhs: Self::Left, rhs: Self::Right) -> Self::Result
where

View File

@ -1,3 +1,4 @@
#![allow(deprecated)]
// Copyright (c) 2017-present PyO3 Project and Contributors
//! Python Async/Await Interface.
@ -15,6 +16,7 @@ use crate::{PyClass, PyObject};
///
/// Each method in this trait corresponds to Python async/await implementation.
#[allow(unused_variables)]
#[deprecated(since = "0.16.0", note = "prefer `#[pymethods]` to `#[pyproto]`")]
pub trait PyAsyncProtocol<'p>: PyClass {
fn __await__(slf: Self::Receiver) -> Self::Result
where

View File

@ -11,6 +11,7 @@ use std::os::raw::c_int;
/// Sequence interface
#[allow(unused_variables)]
#[deprecated(since = "0.16.0", note = "prefer `#[pymethods]` to `#[pyproto]`")]
pub trait PySequenceProtocol<'p>: PyClass + Sized {
fn __len__(&'p self) -> Self::Result
where

View File

@ -1,6 +1,7 @@
#![cfg(feature = "macros")]
#![cfg(feature = "pyproto")]
#![cfg(any(not(Py_LIMITED_API), Py_3_11))]
#![allow(deprecated)]
use pyo3::buffer::PyBuffer;
use pyo3::class::PyBufferProtocol;

View File

@ -1,5 +1,6 @@
#![cfg(feature = "macros")]
#![cfg(feature = "pyproto")]
#![allow(deprecated)]
use pyo3::class::PyGCProtocol;
use pyo3::class::PyTraverseError;

View File

@ -1,5 +1,6 @@
#![cfg(feature = "macros")]
#![cfg(feature = "pyproto")]
#![allow(deprecated)]
use std::collections::HashMap;

View File

@ -1,5 +1,6 @@
#![cfg(feature = "macros")]
#![cfg(feature = "pyproto")]
#![allow(deprecated)]
use pyo3::class::{
PyAsyncProtocol, PyDescrProtocol, PyIterProtocol, PyMappingProtocol, PyObjectProtocol,

View File

@ -1,5 +1,6 @@
#![cfg(feature = "macros")]
#![cfg(feature = "pyproto")]
#![allow(deprecated)]
use pyo3::class::PySequenceProtocol;
use pyo3::exceptions::{PyIndexError, PyValueError};