Skip to content

Commit

Permalink
Add changelog entry detailing how much further impl FromPyObject for …
Browse files Browse the repository at this point in the history
…Vec<T> was relaxed.
  • Loading branch information
adamreichold committed Sep 21, 2022
1 parent 78b4f8f commit 5df7818
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions newsfragments/2632.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
`impl FromPyObject for Vec<T>` will accept any Python object that can be turned into an iterator via Python's built-in `iter` function. It will also not reject `str` anymore which can be iterated as a sequence of `str` objects, i.e. [#2500](https://github.com/PyO3/pyo3/pull/2500) was reverted. Please use a type like

```rust
#[derive(FromPyObject)]
pub enum OneOrMany<'py> {
One(&'py PyString),
Many(Vec<&'py PyString>),
}
```

if you would like to work around this edge case for callers of your API.

0 comments on commit 5df7818

Please sign in to comment.