ltp
ltp copied to clipboard
⬆️ Update pyo3 requirement from 0.19 to 0.20
Updates the requirements on pyo3 to permit the latest version.
Release notes
Sourced from pyo3's releases.
PyO3 0.20.0
This release is the first PyO3 release to be dual-licensed under Apache 2.0 OR MIT licensing (expanding from just Apache 2.0 of previous releases).
Python 3.12 stable is now supported. The minimum supported Rust version has been increased to Rust 1.56.
The
__eq__
,__ne__
,__lt__
,__le__
,__gt__
and__ge__
magic methods are now usable in#[pymethods]
to implement Python operators as an alternative to the__richcmp__
method PyO3 already offered.
#[pyclass(rename_all = "renaming_rule")]
has been added to rename all fields of structs exposed to Python (e.g.rename_all = "snake_case"
) .
PyDict::get_item
now returnsResult<Option<&PyAny>>
instead of justOption<&PyAny>
. The previous implementation which ignored Python errors used APIs now considered deprecated by the Python language designers; it is now considered best practice to bubble up any exception raised during dictionary__getitem__
. For most users migration for this change will simply require addition of a?
on each use ofPyDict::get_item
.Note that Python 3.7 is end of life but PyO3 will continue to support for now as a number of downstream Python packages still have high proportions of downloads on 3.7. A future release is expected to drop Python 3.7 when these numbers reduce.
There have been numerous other smaller improvements, changes and fixes. For full details see the CHANGELOG.
Please consult the migration guide for help upgrading.
Thank you to everyone who contributed code, documentation, design ideas, bug reports, and feedback. The following users' commits are included in this release:
@adamreichold
@adriangb
@alex
@BooleanCat
@CallMeMSL
@cdce8p
@DataTriny
@davidhewitt
@ecarrara
@GoldsteinE
@grantslatton
@Hofer-Julian
@ijl
@iliya-malecki
@jakelishman
@jeffs
@juntyr
@krpatter-intc
@lucatrv
@mejrs
@messense
@mhils
@panpilkarz
@puradox
@ringsaturn
@rytheo
@SigureMo
@smheidrich
@Tpt
@youknowone
@zakstucke
Changelog
Sourced from pyo3's changelog.
[0.20.0] - 2023-10-11
Packaging
- Dual-license PyO3 under either the Apache 2.0 OR the MIT license. This makes the project GPLv2 compatible. #3108
- Update MSRV to Rust 1.56. #3208
- Bump
indoc
dependency to 2.0 andunindent
dependency to 0.2. #3237- Bump
syn
dependency to 2.0. #3239- Drop support for debug builds of Python 3.7. #3387
- Bump
chrono
optional dependency to require 0.4.25 or newer. #3427- Support Python 3.12. #3488
Added
- Support
__lt__
,__le__
,__eq__
,__ne__
,__gt__
and__ge__
in#[pymethods]
. #3203- Add FFI definition
Py_GETENV
. #3336- Add
as_ptr
andinto_ptr
inherent methods forPy
,PyAny
,PyRef
, andPyRefMut
. #3359- Implement
DoubleEndedIterator
forPyTupleIterator
andPyListIterator
. #3366- Add
#[pyclass(rename_all = "...")]
option: this allows renaming all getters and setters of a struct, or all variants of an enum. Available renaming rules are:"camelCase"
,"kebab-case"
,"lowercase"
,"PascalCase"
,"SCREAMING-KEBAB-CASE"
,"SCREAMING_SNAKE_CASE"
,"snake_case"
,"UPPERCASE"
. #3384- Add FFI definitions
PyObject_GC_IsTracked
andPyObject_GC_IsFinalized
on Python 3.9 and up (PyPy 3.10 and up). #3403- Add types for
None
,Ellipsis
, andNotImplemented
. #3408- Add FFI definitions for the
Py_mod_multiple_interpreters
constant and its possible values. #3494- Add FFI definitions for
PyInterpreterConfig
struct, its constants andPy_NewInterpreterFromConfig
. #3502Changed
- Change
PySet::discard
to returnPyResult<bool>
(previously returned nothing). #3281- Optimize implmentation of
IntoPy
for Rust tuples to Python tuples. #3321- Change
PyDict::get_item
to no longer suppress arbitrary exceptions (the return type is nowPyResult<Option<&PyAny>>
instead ofOption<&PyAny>
), and deprecatePyDict::get_item_with_error
. #3330- Deprecate FFI definitions which are deprecated in Python 3.12. #3336
AsPyPointer
is now anunsafe trait
. #3358- Accept all
os.PathLike
values in implementation ofFromPyObject
forPathBuf
. #3374- Add
__builtins__
to globals inpy.run()
andpy.eval()
if they're missing. #3378- Optimize implementation of
FromPyObject
forBigInt
andBigUint
. #3379PyIterator::from_object
andPyByteArray::from
now take a single argument of type&PyAny
(previously took two argumentsPython
andAsPyPointer
). #3389- Replace
AsPyPointer
withAsRef<PyAny>
as a bound in the blanket implementation ofFrom<&T> for PyObject
. #3391- Replace blanket
impl IntoPy<PyObject> for &T where T: AsPyPointer
with implementations ofimpl IntoPy<PyObject>
for&PyAny
,&T where T: AsRef<PyAny>
, and&Py<T>
. #3393- Preserve
std::io::Error
kind in implementation ofFrom<std::io::IntoInnerError>
forPyErr
#3396- Try to select a relevant
ErrorKind
in implementation ofFrom<PyErr>
forOSError
subclass. #3397- Retrieve the original
PyErr
in implementation ofFrom<std::io::Error>
forPyErr
if thestd::io::Error
has been built using a Python exception (previously would create a new exception wrapping thestd::io::Error
). #3402#[pymodule]
will now return the same module object on repeated import by the same Python interpreter, on Python 3.9 and up. #3446- Truncate leap-seconds and warn when converting
chrono
types to Pythondatetime
types (datetime
cannot represent leap-seconds). #3458Err
returned from#[pyfunction]
will now have a non-None__context__
if called from inside acatch
block. #3455- Deprecate undocumented
#[__new__]
form of#[new]
attribute. #3505Removed
... (truncated)
Commits
c77deee
release: 0.20.0b03c4cb
Merge pull request #3506 from davidhewitt/default-nee1d4173
Fix bug in default implementation of__ne__
b73c069
Merge pull request #3504 from davidhewitt/classmethod-receiver76bf521
Merge pull request #3505 from davidhewitt/deprecate_dunder_new6c90325
deprecate undocumented#[__new__]
form of#[new]
c0b5004
Merge pull request #3455 from davidhewitt/normalized-exceptions80bbb30
Merge pull request #3500 from ecarrara/fix-eval-frame-py311ddc04ea
emit helpful error hint for classmethod with receiver0e0e662
fix _PyFrameEvalFunction. Since python 3.11 it receives a_PyInterpreterFrame
- Additional commits viewable in compare view
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase
.
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
-
@dependabot rebase
will rebase this PR -
@dependabot recreate
will recreate this PR, overwriting any edits that have been made to it -
@dependabot merge
will merge this PR after your CI passes on it -
@dependabot squash and merge
will squash and merge this PR after your CI passes on it -
@dependabot cancel merge
will cancel a previously requested merge and block automerging -
@dependabot reopen
will reopen this PR if it is closed -
@dependabot close
will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually -
@dependabot show <dependency name> ignore conditions
will show all of the ignore conditions of the specified dependency -
@dependabot ignore this major version
will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) -
@dependabot ignore this minor version
will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) -
@dependabot ignore this dependency
will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)