Skip to content

Commit

Permalink
feature gate deprecated APIs for PyList (#4127)
Browse files Browse the repository at this point in the history
  • Loading branch information
Icxolu committed Apr 30, 2024
1 parent 82c00a2 commit 2f3a33f
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 94 deletions.
4 changes: 2 additions & 2 deletions guide/src/migration.md
Expand Up @@ -75,7 +75,7 @@ Python::with_gil(|py| {

After:

```rust
```rust,ignore
# use pyo3::prelude::*;
# use pyo3::types::{PyInt, PyList};
# fn main() -> PyResult<()> {
Expand Down Expand Up @@ -1089,7 +1089,7 @@ An additional advantage of using Rust's indexing conventions for these types is
that these types can now also support Rust's indexing operators as part of a
consistent API:

```rust
```rust,ignore
#![allow(deprecated)]
use pyo3::{Python, types::PyList};
Expand Down
4 changes: 4 additions & 0 deletions guide/src/types.md
Expand Up @@ -330,8 +330,10 @@ For a `&PyAny` object reference `any` where the underlying object is a Python-na
a list:

```rust
# #![allow(unused_imports)]
# use pyo3::prelude::*;
# use pyo3::types::PyList;
# #[cfg(feature = "gil-refs")]
# Python::with_gil(|py| -> PyResult<()> {
#[allow(deprecated)] // PyList::empty is part of the deprecated "GIL Refs" API.
let obj: &PyAny = PyList::empty(py);
Expand Down Expand Up @@ -390,8 +392,10 @@ To see all Python types exposed by `PyO3` consult the [`pyo3::types`][pyo3::type
**Conversions:**

```rust
# #![allow(unused_imports)]
# use pyo3::prelude::*;
# use pyo3::types::PyList;
# #[cfg(feature = "gil-refs")]
# Python::with_gil(|py| -> PyResult<()> {
#[allow(deprecated)] // PyList::empty is part of the deprecated "GIL Refs" API.
let list = PyList::empty(py);
Expand Down

0 comments on commit 2f3a33f

Please sign in to comment.