Skip to content

Commit 2f3a33f

Browse files
authored
feature gate deprecated APIs for PyList (#4127)
1 parent 82c00a2 commit 2f3a33f

File tree

3 files changed

+104
-94
lines changed

3 files changed

+104
-94
lines changed

guide/src/migration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Python::with_gil(|py| {
7575

7676
After:
7777

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

1092-
```rust
1092+
```rust,ignore
10931093
#![allow(deprecated)]
10941094
use pyo3::{Python, types::PyList};
10951095

guide/src/types.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,10 @@ For a `&PyAny` object reference `any` where the underlying object is a Python-na
330330
a list:
331331

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

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

0 commit comments

Comments
 (0)