From ed1469cb061f1c8939f6d6f87ad5ae1d9df6856d Mon Sep 17 00:00:00 2001 From: Adam Reichold Date: Wed, 21 Sep 2022 10:11:12 +0200 Subject: [PATCH] Add changelog entry detailing how much further impl FromPyObject for Vec was relaxed. --- newsfragments/2632.changed.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 newsfragments/2632.changed.md diff --git a/newsfragments/2632.changed.md b/newsfragments/2632.changed.md new file mode 100644 index 00000000000..8a957fa0ba7 --- /dev/null +++ b/newsfragments/2632.changed.md @@ -0,0 +1,11 @@ +`impl FromPyObject for Vec` 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.