Update Rust crate pyo3 to 0.20.3 - autoclosed #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
0.16.5
->0.20.3
Release Notes
pyo3/pyo3 (pyo3)
v0.20.3
: PyO3 0.20.3Compare Source
This is a stability & compatibility release to fix a couple of minor compilation edge cases from PyO3 0.20.2.
The
portable-atomic
dependency has been added to resolve compile failures on platforms without 64-bit atomic support.A maximum Python version check (currently for Python 3.12) has been added to prevent using old PyO3 code against future Python versions beyond the supported range.
Thank you to the following users for the improvements:
@adamreichold
@davidhewitt
v0.20.2
Compare Source
Packaging
pyo3
andpyo3-ffi
dependencies onpyo3-build-config
to require the same patch version, i.e.pyo3
0.20.2 requires exactlypyo3-build-config
0.20.2. #3721Fixed
pyo3
0.20.0 with latestpyo3-build-config
0.20.X. #3724v0.20.1
Compare Source
Added
either
feature to add conversions foreither::Either<L, R>
sum type. #3456smallvec
feature to add conversions forsmallvec::SmallVec
. #3507take
andinto_inner
methods toGILOnceCell
#3556#[classmethod]
methods can now also receivePy<PyType>
as their first argument. #3587#[pyfunction(pass_module)]
can now also receivePy<PyModule>
as their first argument. #3587traverse
method toGILProtected
. #3616abi3-py312
feature #3687Fixed
chrono
dependency. #3512clippy::unnecessary_fallible_conversions
warning when using aPy<Self>
self
receiver. #3564v0.20.0
Compare Source
Packaging
indoc
dependency to 2.0 andunindent
dependency to 0.2. #3237syn
dependency to 2.0. #3239chrono
optional dependency to require 0.4.25 or newer. #3427Added
__lt__
,__le__
,__eq__
,__ne__
,__gt__
and__ge__
in#[pymethods]
. #3203Py_GETENV
. #3336as_ptr
andinto_ptr
inherent methods forPy
,PyAny
,PyRef
, andPyRefMut
. #3359DoubleEndedIterator
forPyTupleIterator
andPyListIterator
. #3366#[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"
. #3384PyObject_GC_IsTracked
andPyObject_GC_IsFinalized
on Python 3.9 and up (PyPy 3.10 and up). #3403None
,Ellipsis
, andNotImplemented
. #3408Py_mod_multiple_interpreters
constant and its possible values. #3494PyInterpreterConfig
struct, its constants andPy_NewInterpreterFromConfig
. #3502Changed
PySet::discard
to returnPyResult<bool>
(previously returned nothing). #3281IntoPy
for Rust tuples to Python tuples. #3321PyDict::get_item
to no longer suppress arbitrary exceptions (the return type is nowPyResult<Option<&PyAny>>
instead ofOption<&PyAny>
), and deprecatePyDict::get_item_with_error
. #3330AsPyPointer
is now anunsafe trait
. #3358os.PathLike
values in implementation ofFromPyObject
forPathBuf
. #3374__builtins__
to globals inpy.run()
andpy.eval()
if they're missing. #3378FromPyObject
forBigInt
andBigUint
. #3379PyIterator::from_object
andPyByteArray::from
now take a single argument of type&PyAny
(previously took two argumentsPython
andAsPyPointer
). #3389AsPyPointer
withAsRef<PyAny>
as a bound in the blanket implementation ofFrom<&T> for PyObject
. #3391impl IntoPy<PyObject> for &T where T: AsPyPointer
with implementations ofimpl IntoPy<PyObject>
for&PyAny
,&T where T: AsRef<PyAny>
, and&Py<T>
. #3393std::io::Error
kind in implementation ofFrom<std::io::IntoInnerError>
forPyErr
#3396ErrorKind
in implementation ofFrom<PyErr>
forOSError
subclass. #3397PyErr
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. #3446chrono
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#[__new__]
form of#[new]
attribute. #3505Removed
#[args]
attribute for#[pymethods]
. #3232IntoPyPointer
trait in favour ofinto_ptr
inherent methods. #3385Fixed
PySet::discard
. #3281PyTupleIterator
type returned byPyTuple::iter
is now public and hence can be named by downstream crates. #3366PyOS_FSPath
on PyPy. #3374PyTypeBuilder::build
. #3401_Py_GetAllocatedBlocks
,_PyObject_GC_Malloc
, and_PyObject_GC_Calloc
on Python 3.11 and up. #3403ResourceWarning
and crashes related to GC when running with debug builds of CPython. #3404Option<T>
default arguments will no longer re-wrapSome(T)
or expressions evaluating toNone
. #3461IterNextOutput::Return
not returning a value on PyPy. #3471#[pymethods]
blocks. #3491#[new]
,#[classmethod]
,#[staticmethod]
, and#[classattr]
. #3484PyMarshal_WriteObjectToString
fromPyMarshal_ReadObjectFromString
with theabi3
feature. #3490_PyFrameEvalFunction
on Python 3.11 and up (it now receives a_PyInterpreterFrame
opaque struct). #3500v0.19.2
Compare Source
Added
PyState_AddModule
,PyState_RemoveModule
andPyState_FindModule
for PyPy 3.9 and up. #3295_PyObject_CallFunction_SizeT
and_PyObject_CallMethod_SizeT
. #3297PyErr::Display
for all Python versions, and FFI symbolPyErr_DisplayException
for Python 3.12. #3334PyType_GetDict()
for Python 3.12. #3339PyAny::downcast_exact
. #3346PySlice::full()
to construct a full slice (::
). #3353Changed
PyErr
for 3.12 betas to avoid deprecated ffi methods. #3306object.h
for Python 3.12.0b4. #3335pyo3::ffi
struct definitions to be compatible with 3.12.0b4. #3342float
tof64
(andPyFloat::value
) on non-abi3 builds. #3345Fixed
SystemError
raised inPyUnicodeDecodeError_Create
on PyPy 3.10. #3297Py_EnterRecursiveCall
to returnc_int
(was incorrectly returning()
). #3300PyErr::matches
andPyErr::is_instance
returned results inconsistent withPyErr::get_type
. #3313PanicException
when unwinding after the exception was "normalized". #3326PyErr::from_value
andPyErr::into_value
losing traceback on conversion. #3328v0.19.1
Compare Source
Packaging
hashbrown
optional dependency to include version 0.14 #3258indexmap
optional dependency to include version 2. #3277Added
pyo3::types::PyFrozenSetBuilder
to allow building aPyFrozenSet
item by item. #3156ipaddress.IPv4Address
/ipaddress.IPv6Address
andstd::net::IpAddr
. #3197num-bigint
feature in combination withabi3
. #3198PyErr_GetRaisedException()
,PyErr_SetRaisedException()
to FFI definitions for Python 3.12 and later. #3248Python::with_pool
which is a safer but more limited alternative toPython::new_pool
. #3263PyDict::get_item_with_error
on PyPy. #3270#[new]
methods may to returnPy<Self>
in order to return existing instances. #3287Fixed
__complex__
toComplex
when usingabi3
or PyPy. #3185PyAny::hasattr
. #3271PySet
orPyFrozenSet
or returning types converted into these internally, e.g.HashSet
orBTreeSet
. #3286v0.19.0
Compare Source
Packaging
Added
text_signature
option (and automatically generate signature) for#[new]
in#[pymethods]
. #2980decimal.Decimal
andrust_decimal::Decimal
. #3016#[pyo3(from_item_all)]
when derivingFromPyObject
to specifyget_item
as getter for all fields. #3120pyo3::exceptions::PyBaseExceptionGroup
for Python 3.11, and corresponding FFI definitionPyExc_BaseExceptionGroup
. #3141#[new]
with#[classmethod]
to create a constructor which receives a (subtype's) class/PyType
as its first argument. #3157PyClass::get
andPy::get
for GIL-indepedent access to classes with#[pyclass(frozen)]
. #3158PyAny::is_exact_instance
andPyAny::is_exact_instance_of
. #3161Changed
PyAny::is_instance_of::<T>(obj)
is now equivalent toT::is_type_of(obj)
, and now returnsbool
instead ofPyResult<bool>
. #2881text_signature
option on#[pyclass]
structs. #2980anyhow::Error
/eyre::Report
containing a basicPyErr
without a chain in aPyRuntimeError
. #3004#[getter]
and#[setter]
to use a common call "trampoline" to slightly reduce generated code size and compile times. #3029text_signature
. #3050None
in automatically-generatedtext_signature
. #3066PySequence::list
andPySequence::tuple
toPySequence::to_list
andPySequence::to_tuple
. (The old names continue to exist as deprecated forms.) #3111PyRef::py
andPyRefMut::py
to match the underlying borrow. #3131Python::with_gil
, is now locked inside of implementations of the__traverse__
slot. #3168Removed
Python::acquire_gil
is replaced byPython::with_gil
. #2981Fixed
PyGetSetDef
,PyMemberDef
,PyStructSequence_Field
andPyStructSequence_Desc
to have*const c_char
members forname
anddoc
(not*mut c_char
). #3036fmt::Display
, instead return"<unprintable object>"
string and report error viasys.unraisablehook()
#3062#[pyfunction]
s take references into#[pyclass]
es #3142__traverse__
implementation. #3168Drop
implementations of unsendable classes on other threads. #3176#[pymethods]
items come from somewhere else (for example, as a macro argument) and a custom receiver likePy<Self>
is used. #3178v0.18.3
Compare Source
Added
GILProtected<T>
to mediate concurrent access to a value using Python's global interpreter lock (GIL). #2975PyASCIIObject
/PyUnicode
and associated methods on big-endian architectures. #3015_PyDict_Contains_KnownHash()
for CPython 3.10 and up. #3088Fixed
#[pymethods]
and#[pyfunction]
called "output". #3022#[staticmethod]
. #3055is_instance
forPyDateTime
(would incorrectly check for aPyDate
). #3071PyUnicode_InternImmortal
since Python 3.10. #3071v0.18.2
Compare Source
Packaging
chrono
to avoid depending ontime
v0.1.x. #2939Added
IntoPy<PyObject>
,ToPyObject
andFromPyObject
forCow<[u8]>
to efficiently handle bothbytes
andbytearray
objects. #2899IntoPy<PyObject>
,ToPyObject
andFromPyObject
forCell<T>
. #3014PyList::to_tuple()
, as a convenient and efficient conversion from lists to tuples. #3042PyTuple::to_list()
, as a convenient and efficient conversion from tuples to lists. #3044Changed
PySequence
conversion forlist
andtuple
inputs. #2944#[pyclass]
type object fails during module import. #2947PyMapping
conversion fordict
inputs. #2954create_exception!
to take adotted.module
to place the exception in a submodule. #2979Fixed
PyObject
s cloned inallow_threads
blocks. #2952clippy::redundant_closure
lint on default arguments in#[pyo3(signature = (...))]
annotations. #2990non_snake_case
lint on generated code in#[pyfunction]
macro. #2993v0.18.1
Compare Source
Added
PyErr::write_unraisable()
. #2889Python::Ellipsis()
andPyAny::is_ellipsis()
methods. #2911PyDict::update()
andPyDict::update_if_missing()
methods. #2912Changed
PyIter_Check
on CPython 3.7 is now implemented ashasattr(type(obj), "__next__")
, which works correctly on all platforms and adds support forabi3
. #2914PYO3_CONFIG_FILE
instead of denying. #2926Fixed
__releasebuffer__
tosys.unraisablehook
rather than causingSystemError
. #2886PyIterator
succeeding for Python classes which did not implement__next__
. #2914__traverse__
when visitingNone
fields ofOption<T: AsPyPointer>
. #2921#[pymethods(crate = "...")]
option being ignored. #2923pythonXY_d.dll
for debug Python builds on Windows. #2937v0.18.0
Compare Source
Packaging
indexmap
optional depecency to allow>= 1.6, < 2
. #2849hashbrown
optional dependency to allow>= 0.9, < 0.14
. #2875memoffset
dependency to 0.8. #2875Added
GILOnceCell::get_or_try_init
for fallibleGILOnceCell
initialization. #2398experimental-inspect
withtype_input()
andtype_output()
helpers to get the Python type of any Python-compatible object. #2490 #2882#[pyclass]
macro can now takeget_all
andset_all
to create getters and setters for every field. #2692#[pyo3(signature = (...))]
option for#[pyfunction]
and#[pymethods]
. #2702pyo3-build-config
: rebuild whenPYO3_ENVIRONMENT_SIGNATURE
environment variable value changes. #2727std::num
and Pythonint
. #2730Py::downcast()
as a companion toPyAny::downcast()
, as well asdowncast_unchecked()
for both types. #2734Warning
classes as well asPyErr::warn_explicit
. #2742abi3-py311
feature. #2776_PyErr_ChainExceptions()
for CPython. #2788PyVectorcall_NARGS
andPY_VECTORCALL_ARGUMENTS_OFFSET
for PyPy 3.8 and up. #2811PyList::get_item_unchecked
for PyPy. #2827Changed
PyCFunction::new_closure
to takename
anddoc
arguments. #2686PyType::is_subclass
,PyErr::is_instance
andPyAny::is_instance
now take&PyAny
instead of&PyType
arguments, so that they work with objects that pretend to be types using__subclasscheck__
and__instancecheck__
. #2695#[args]
attribute and passing "args" specification directly to#[pyfunction]
in favor of the new#[pyo3(signature = (...))]
option. #2702Option<T>
arguments to#[pyfunction]
and#[pymethods]
without also using#[pyo3(signature)]
to specify whether the arguments should be required or have defaults. #2703#[pyfunction]
and#[pymethods]
to use a common call "trampoline" to slightly reduce generated code size and compile times. #2705PyAny::cast_as()
andPy::cast_as()
are now deprecated in favor ofPyAny::downcast()
and the newPy::downcast()
. #2734PyAny::downcast()
. #2734__text_signature__
for all Python functions created using#[pyfunction]
and#[pymethods]
. #2784PySet::new
andPyFrozenSet::new
. #2795#[cfg(...)]
and#[pyo3(...)]
attributes on#[pyclass]
struct fields will now work. #2796PyFunction
on when building for abi3 or PyPy. #2838derive(FromPyObject)
to useintern!
when applicable for#[pyo3(item)]
. #2879Removed
pyproto
feature,#[pyproto]
macro, and all accompanying APIs. #2587Fixed
PyModule::filename
on PyPy. #2715PyCodeObject
is now once again defined with fields on Python 3.7. #2726TypeError
if#[new]
pymethods with no arguments receive arguments when called from Python. #2749NOARGS
argument calling convention for methods that have a singlepy: Python
argument (as a performance optimization). #2760isize
values toc_long
inPySlice::new
. #2769PyUnicodeDecodeError_Create
on PyPy leading to indeterminate behavior (typically aTypeError
). #2772**kwargs
to accept keyword arguments which share a name with a positional-only argument (as permitted by PEP 570). #2800PyObject_Vectorcall
on PyPy 3.9 and up. #2811PyCFunction::new_closure
. #2842v0.17.3
Compare Source
Packaging
Added
ExactSizeIterator
forPyListIterator
,PyDictIterator
,PySetIterator
andPyFrozenSetIterator
. #2676Fixed
impl FromPyObject for [T; N]
no longer accepting types passingPySequence_Check
, e.g. NumPy arrays, since version 0.17.0. This the same fix that was appliedimpl FromPyObject for Vec<T>
in version 0.17.1 extended to fixed-size arrays. #2675FunctionDescription::extract_arguments_fastcall
due to creating slices from a null pointer. #2687v0.17.2
Compare Source
Packaging
chrono
feature to convertchrono
types into types in thedatetime
module. #2612Added
num-bigint
feature onPyPy
. #2626Fixed
__richcmp__
for enums, fixing__ne__
returning always returningTrue
. #2622Option<&SomePyClass>
argument with a default. #2630impl FromPyObject for Vec<T>
no longer accepting types passingPySequence_Check
, e.g. NumPy arrays, since 0.17.0. #2631v0.17.1
Compare Source
Fixed
PyDictItems
,PyDictKeys
, andPyDictValues
types added in PyO3 0.17.0.#[pyo3(from_py_with = "...")]
attribute on an argument of typeOption<T>
. #2592redundant-closure
lint on**kwargs
arguments for#[pyfunction]
and#[pymethods]
. #2595v0.17.0
Compare Source
Packaging
0.3
(themultiple-pymethods
feature now requires Rust 1.62 for correctness). #2492Added
timezone_utc
. #1588ToPyObject
for[T; N]
. #2313PyDictKeys
,PyDictValues
andPyDictItems
Rust types. #2358append_to_inittab
. #2377PyFrame_GetCode
. #2406PyCode
andPyFrame
high level objects. #2408Py_fstring_input
,sendfunc
, and_PyErr_StackItem
. #2423PyDateTime::new_with_fold
,PyTime::new_with_fold
,PyTime::get_fold
, andPyDateTime::get_fold
for PyPy. #2428#[pyclass(frozen)]
. #2448#[pyo3(name)]
on enum variants. #2457CompareOp::matches
to implement__richcmp__
as the result of a Ruststd::cmp::Ordering
comparison. #2460PySuper
type. #2486generate-import-lib
feature. #2506Py_EnterRecursiveCall
andPy_LeaveRecursiveCall
. #2511PyDict::get_item_with_error
. #2536#[pyclass(sequence)]
option. #2567Changed
tzinfo
to takeOption<&PyTzInfo>
instead ofOption<&PyObject>
:PyDateTime::new
,PyDateTime::new_with_fold
,PyTime::new
, andPyTime::new_with_fold
. #1588PyTypeObject::type_object
method to thePyTypeInfo
trait, and deprecate thePyTypeObject
trait. #2287Py
andPyAny
now acceptimpl IntoPy<Py<PyString>>
rather than just&str
to allow use of theintern!
macro. #2312pyproto
feature to be opt-in instead of opt-out. #2322#[pyfunction]
return types do not implementIntoPy
. #2326T: IntoPy
forimpl<T, const N: usize> IntoPy<PyObject> for [T; N]
instead ofT: ToPyObject
. #2326ToBorrowedObject
trait. #2333PySet
andPyDict
will now panic if the underlying collection is mutated during the iteration. #2380PySet
andPyDict
will now panic if the underlying collection is mutated during the iteration. #2380#[classattr]
methods to be fallible. #2385#[pymethods]
with the same name for a single#[pyclass]
. #2399lib_name
when usingPYO3_CONFIG_FILE
. #2404ValueError
raised by the#[derive(FromPyObject)]
implementation for a tuple struct. #2414#[classattr]
methods to takePython
argument. #2456PyCapsule
type to resolve soundness issues: #2485PyCapsule::new
andPyCapsule::new_with_destructor
now takename: Option<CString>
instead of&CStr
.F
inPyCapsule::new_with_destructor
must now beSend
.PyCapsule::get_context
deprecated in favor ofPyCapsule::context
which doesn't take apy: Python<'_>
argument.PyCapsule::set_context
no longer takes apy: Python<'_>
argument.PyCapsule::name
now returnsPyResult<Option<&CStr>>
instead of&CStr
.FromPyObject::extract
forVec<T>
no longer accepts Pythonstr
inputs. #2500#[pymodule]
is only initialized once. #2523pyo3_build_config::add_extension_module_link_args
now also emits linker arguments forwasm32-unknown-emscripten
. #2538PySequence
andPyMapping
now require inputs to inherit from (or register with)collections.abc.Sequence
andcollections.abc.Mapping
respectively. #2477PyFunction
on when building for abi3 or PyPy. #2542Python::acquire_gil
. #2549Removed
Dict
,WeakRef
andBaseNativeType
members of thePyClass
private implementation details. #2572Fixed
PyThreadState_DeleteCurrent
. #2357wrap_pymodule
interactions with name resolution rules: it no longer "sees through" glob imports ofuse submodule::*
whensubmodule::submodule
is a#[pymodule]
. #2363PyEval_EvalCodeEx
to take*const *mut PyObject
array arguments instead of*mut *mut PyObject
. #2368#[pyclass] struct r#RawName
) incorrectly havingr#
at the start of the class name created in Python. #2395Py_tracefunc
to beunsafe extern "C" fn
(was previously safe). #2407#[pyo3(from_py_with = "...")]
annotations on a field in a#[derive(FromPyObject)]
struct. #2414_PyDateTime_BaseTime
and_PyDateTime_BaseDateTime
lacking leading underscores in their names. #2421PyArena
on Python 3.10 and up. #2421PyCompilerFlags
missing membercf_feature_version
on Python 3.8 and up. #2423PyAsyncMethods
missing memberam_send
on Python 3.10 and up. #2423PyGenObject
having multiple incorrect members on various Python versions. #2423PySyntaxErrorObject
missing membersend_lineno
andend_offset
on Python 3.10 and up. #2423PyHeapTypeObject
missing memberht_module
on Python 3.9 and up. #2423PyFrameObject
having multiple incorrect members on various Python versions. #2424 #2434PyTypeObject
missing deprecated fieldtp_print
on Python 3.8. #2428PyDateTime_CAPI
.PyDateTime_Date
,PyASCIIObject
,PyBaseExceptionObject
,PyListObject
, andPyTypeObject
on PyPy. #2428_inittab
fieldinitfunc
typo'd asinitfun
. #2431_PyDateTime_BaseTime
and_PyDateTime_BaseDateTime
incorrectly havingfold
member. #2432PyTypeObject
.PyHeapTypeObject
, andPyCFunctionObject
having incorrect members on PyPy 3.9. #2433PyGetSetDef
to have*const c_char
fordoc
member (not*mut c_char
). #2439#[pyo3(from_py_with = "...")]
being ignored for 1-element tuple structs and transparent structs. #2440memoffset
to avoid UB when computingPyCell
layout. #2450repr
for enums renamed by#[pyclass(name = "...")]
#2457PyObject_CallNoArgs
incorrectly being available when building for abi3 on Python 3.9. #2476#[pyfunction]
arguments. #2503v0.16.6
Compare Source
Changed
PyCapsule
type with select workarounds. Users are encourage to upgrade to PyO3 0.17 at their earliest convenience which contains API breakages which fix the issues in a long-term fashion. #2522PyCapsule::new
andPyCapsule::new_with_destructor
now take ownership of a copy of thename
to resolve a possible use-after-free.PyCapsule::name
now returns an emptyCStr
instead of dereferencing a null pointer if the capsule has no name.F
inPyCapsule::new_with_destructor
will never be called if the capsule is deleted from a thread other than the one which the capsule was created in (a warning will be emitted).Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Mend Renovate. View repository job log here.