Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions guide/src/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ To migrate, switch all type casts to use `obj.downcast()` instead of `try_from(o

Before:

```rust
```rust,ignore
# #![allow(deprecated)]
# use pyo3::prelude::*;
# use pyo3::types::{PyInt, PyList};
Expand All @@ -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
Original file line number Diff line number Diff line change
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
6 changes: 3 additions & 3 deletions src/types/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2736,13 +2736,13 @@ class SimpleClass:
#[test]
fn test_is_empty() {
Python::with_gil(|py| {
let empty_list: &PyAny = PyList::empty(py);
let empty_list = PyList::empty_bound(py).into_any();
assert!(empty_list.is_empty().unwrap());

let list: &PyAny = PyList::new(py, vec![1, 2, 3]);
let list = PyList::new_bound(py, vec![1, 2, 3]).into_any();
assert!(!list.is_empty().unwrap());

let not_container = 5.to_object(py).into_ref(py);
let not_container = 5.to_object(py).into_bound(py);
assert!(not_container.is_empty().is_err());
});
}
Expand Down
Loading