Sourced from pyo3's releases.
PyO3 0.24.1
This release is a security fix for the
PyString::from_objectmethod, which passed&strdata to the Python C API without checking for a terminating nul byte. All historical PyO3 versions are affected, and we recommend you upgrade if you are usingPyString::from_object. Thank you to@vthibfor the report and@Dr-Emannfor the fix. A RUSTSEC advisory will be published shortly.Aside from the security fix, this release contains a number of other non-breaking additions:
- An
abi3-py313feature to support compiling with the Python 3.13 stable ABI.PyAnyMethods::getattr_optto get optional attributes without paying the cost of a Python exception when the attribute in question does not exist.- Constructor for
PyInt::new.with_critical_section2for locking two objects at the same time on the free-threaded build.- Fix for a PyO3 0.24.0 regression with
Option<&str>andOption<&T>(whereT: PyClass) function arguments no longer being permittedThere are also a few other small bug fixes for edge cases, mostly related to compile errors from PyO3's macro code.
Thank you to the following contributors for the improvements:
@bschoenmaeckers@davidhewitt@Dr-Emann@emmagordon@epontan@Icxolu@IvanIsCoding@jelmer@jonaspleyer@ngoldbaum@Owen-CH-Leung@Tpt@Trolldemorted@XuehaiPanPyO3 0.24.0
This release is an incremental improvement of refinements and optimizations following the new APIs established in PyO3's last few releases.
Support for
jiffdatetime conversions have been added, and also UUID conversions.The
FromPyObjectderive macro has gained new#[pyo3(default = ...)]and#[pyo3(rename_all = ...)]options, and theIntoPyObjectderive macro has gained a new#[pyo3(into_py_with = ...)]option.PyO3 will now pass positional arguments to Python functions using the "vectorcall" protocol in many cases, which should be an optimization over the previous behaviour (of creating a Python tuple of positional arguments).
Many methods on iterators of Python collections have been optimized.
There are also many other incremental improvements, bug fixes and smaller features.
Thank you to everyone who contributed code, documentation, design ideas, bug reports, and feedback. The following contributors' commits are included in this release:
... (truncated)
Sourced from pyo3's changelog.
[0.24.1] - 2025-03-31
Added
- Add
abi3-py313feature. #4969- Add
PyAnyMethods::getattr_opt. #4978- Add
PyInt::newconstructor for all supported number types (i32, u32, i64, u64, isize, usize). #4984- Add
pyo3::sync::with_critical_section2. #4992- Implement
PyCallArgsforBorrowed<'_, 'py, PyTuple>,&Bound<'py, PyTuple>, and&Py<PyTuple>. #5013Fixed
- Fix
is_type_offor native types not using same specialized check asis_type_of_bound. #4981- Fix
Probeclass naming issue with#[pymethods]. #4988- Fix compile failure with required
#[pyfunction]arguments takingOption<&str>andOption<&T>(for#[pyclass]types). #5002- Fix
PyString::from_objectcausing of bounds reads withencodinganderrorsparameters which are not nul-terminated. #5008- Fix compile error when additional options follow after
cratefor#[pyfunction]. #5015[0.24.0] - 2025-03-09
Packaging
- Add supported CPython/PyPy versions to cargo package metadata. #4756
- Bump
target-lexicondependency to 0.13. #4822- Add optional
jiffdependency to add conversions forjiffdatetime types. #4823- Add optional
uuiddependency to add conversions foruuid::Uuid. #4864- Bump minimum supported
inventoryversion to 0.3.5. #4954Added
- Add
PyIterator::sendmethod to allow sending values into a python generator. #4746- Add
PyCallArgstrait for passing arguments into the Python calling protocol. This enabled using a faster calling convention for certain types, improving performance. #4768- Add
#[pyo3(default = ...']option for#[derive(FromPyObject)]to set a default value for extracted fields of named structs. #4829- Add
#[pyo3(into_py_with = ...)]option for#[derive(IntoPyObject, IntoPyObjectRef)]. #4850- Add FFI definitions
PyThreadState_GetFrameandPyFrame_GetBack. #4866- Optimize
lastforBoundListIterator,BoundTupleIteratorandBorrowedTupleIterator. #4878- Optimize
Iterator::count()forPyDict,PyList,PyTuple&PySet. #4878- Optimize
nth,nth_back,advance_byandadvance_back_byforBoundTupleIterator#4897- Add support for
types.GenericAliasaspyo3::types::PyGenericAlias. #4917- Add
MutextExttrait to help avoid deadlocks with the GIL while locking astd::sync::Mutex. #4934- Add
#[pyo3(rename_all = "...")]option for#[derive(FromPyObject)]. #4941Changed
- Optimize
nth,nth_back,advance_byandadvance_back_byforBoundListIterator. #4810- Use
DerefToPyAnyin blanket implementations ofFrom<Py<T>>andFrom<Bound<'py, T>>forPyObject. #4593- Map
io::ErrorKind::IsADirectory/NotADirectoryto the corresponding Python exception on Rust 1.83+. #4747PyAnyMethods::calland friends now requirePyCallArgsfor their positional arguments. #4768- Expose FFI definitions for
PyObject_Vectorcall(Method)on the stable abi on 3.12+. #4853#[pyo3(from_py_with = ...)]now take a path rather than a string literal #4860
... (truncated)
a213b36
release: 0.24.1 (#5021)d85a02d
split PyFunctionArgument to specialize Option
(#5002)c37a50a
Add example of more complex exceptions (#5014)dcacb9b
Simplify PyFunctionArgument impl on &Bound<T> (#5018)03c31c5
fix #[pyfunction] option parsing (#5015)0f49eb1
docs: Remove examples with outdated PyO3 and unmaintained projects (#4952)1b00b0d
implement PyCallArgs for borrowed types (#5013)5caaa37
fix: convert to cstrings in PyString::from_object (#5008)4aca459
docs: guide - add link to tables and traits (#5001)0452c0e
replace quansight-labs/setup-python with actions/setup-python (#5007)