Closed tdyas closed 23 hours ago
GILProtected
changes have been broken out to https://github.com/pantsbuild/pants/pull/21670.
The commits each have a distinct change and can be reviewed individually.
(Just checking that the "[WIP]" in the PR title is no longer true? this is complete?)
(Just checking that the "[WIP]" in the PR title is no longer true? this is complete?)
ah yeah, it is no longer WIP. Will edit.
Only question: with the newly fallible tuple constructor, do we know in what cases it might fail?
Just wondering if some more of them may count as fatal errors (i.e. use
.expect(...)
orpanic!()
more), or be normal/likely-to-occur and thus be worth wrapping in more context to make debugging easier?
I don't know when it is ever expected to fail. I want to say that "regular" Python and Rust std types are not expected to fail in practice, but I can't point to anywhere supporting that position. The migration guide just notes that "conversions can now return an error." And PyTuple::new
is documented to panic if an iterator's ExactSizeIterator
implementation is broken.
I'm going to land this; if need be, subsequent PRs can improve on how to handle PyTuple::new being able to fail.
Thanks for the links, digging through into the source code suggests the fallibility is from IntoPyObject
and the into_pyobject
calls on each element (rather than something about the tuple itself): https://docs.rs/pyo3/0.23.1/src/pyo3/types/tuple.rs.html#103
So, I reckon what you've got here is perfectly fine 👍
Upgrade to v0.23.x of the
pyo3
crate:Functions in PyO3 with
_bound
suffixes existed in PyO3 only for easing migration to theBound
API. They are deprecated now and new methods without the_bound
suffixes have been re-introduced in PyO3. This PR renames call sites accordingly and updates code to also reflect that some of the new APIs (e.g.,PyTuple::new
) are now fallible.The
IntoPy
andToPyObject
traits are deprecated in favor of the newIntoPyObject
trait (which is fallible). To ease migration, this PR only disables deprecation warnings as errors in the affected files. (Unfortunately,IntoPyObject
was not introduced in the current v0.22.x version and so we cannot migrate ahead of the upgrade (unlike what was done in https://github.com/pantsbuild/pants/pull/21670 for the newpyclass
Sync requirement).) Migration will take place in follow-on PRs.IntoPyObject
for&Value
to support some existing call sites.