Skip to content

Releases: PyO3/pyo3

PyO3 0.12.2

12 Oct 19:55
Compare
Choose a tag to compare

This release adds the ability to specify keyword-only arguments in #[pyfunction] definitions, a new function Python::check_signals, and a couple of smaller refinements improving upon PyO3 0.12.1.

Thank you to everyone who contributed code, documentation fixes, design ideas, bug reports, and feedback. The following users' commits are included in this release:

@birkenfeld
@davidhewitt
@dvermd
@kngwyu
@sebpuetz

PyO3 0.12.1

16 Sep 21:16
Compare
Choose a tag to compare

This release contains a couple of bugfixes to resolve complation issues with 0.12.0 on specific targets. Thank you to @alex and @mtreinish for the bug reports and subsequent patches.

Fixed

  • Fix building for a 32-bit Python on 64-bit Windows with a 64-bit Rust toolchain. #1179
  • Fix building on platforms where c_char is u8. #1182

PyO3 0.12.0

12 Sep 22:55
Compare
Choose a tag to compare

This release includes a few careful revisions to the PyO3 API with the intention to make it easier to learn and use. The PyErr type is reworked to implement std::error::Error. The FromPy trait is removed. Finally, the PyObject struct is now just a type alias to Py<PyAny>. While we do not take pleasure in making breaking changes for users' code, we have done so with careful thought to make migration as simple as possible while also allowing the PyO3 API to mature. Please see the migration guide for help upgrading if any of these changes affect you.

Also added is a new #[derive(FromPyObject)] macro, which enables a convenient way to accept arguments of the Python "type" Union. (See the guide entry on this new feature.)

There have been many other improvements and bugfixes too numerous to go into detail here. For the full list, see the CHANGELOG.

Thank you to everyone who contributed code, documentation fixes, design ideas, bug reports, and feedback on the way to PyO3 0.12. The full list of users who commited at least one contribution to PyO3 0.12 is below:

@alex
@birkenfeld
@cathay4t
@davidhewitt
@Hakuyume
@Hywan
@kngwyu
@konstin
@marioortizmanero
@MoritzLangenstein
@mtreinish
@mvaled
@nagisa
@noam93k
@Progdrasil
@programmerjake
@rob-thatcher
@sebpuetz
@vorner
@vthriller

PyO3 0.11.1

03 Jul 03:24
c6abf24
Compare
Choose a tag to compare

#[pyclass(unsendable)] is added, please check the guide!

[0.11.1] - 2020-06-30

Added

  • #[pyclass(unsendable)]. #1009

Changed

  • Update parking_lot dependency to 0.11. #1010

PyO3 0.11.0

28 Jun 09:14
6335a7f
Compare
Choose a tag to compare

This is our first version that supports the stable Rust toolchain. The minimum required version is 1.39.0.
Thank you @davidhewitt @scalexm @tamuhey @konstin @Nateckert @Alexander-N @m-ou-se and all issue reporters 🙂

Maybe the most influential change is now #[pyclass] requires Send. Please see the migration guide for more.

Added

  • Support stable versions of Rust (>=1.39). #969
  • Add FFI definition PyObject_AsFileDescriptor. #938
  • Add PyByteArray::data, PyByteArray::as_bytes, and PyByteArray::as_bytes_mut. #967
  • Add GILOnceCell to use in situations where lazy_static or once_cell can deadlock. #975
  • Add Py::borrow, Py::borrow_mut, Py::try_borrow, and Py::try_borrow_mut for accessing #[pyclass] values. #976
  • Add IterNextOutput and IterANextOutput for returning from __next__ / __anext__. #997

Changed

  • Simplify internals of #[pyo3(get)] attribute. (Remove the hidden API GetPropertyValue.) #934
  • Call Py_Finalize at exit to flush buffers, etc. #943
  • Add type parameter to PyBuffer. #951
  • Require Send bound for #[pyclass]. #966
  • Add Python argument to most methods on PyObject and Py<T> to ensure GIL safety. #970
  • Change signature of PyTypeObject::type_object() - now takes Python argument and returns &PyType. #970
  • Change return type of PyTuple::slice() and PyTuple::split_from() from Py<PyTuple> to &PyTuple. #970
  • Change return type of PyTuple::as_slice to &[&PyAny]. #971
  • Rename PyTypeInfo::type_object to type_object_raw, and add Python argument. #975
  • Update num-complex optional dependendency from 0.2 to 0.3. #977
  • Update num-bigint optional dependendency from 0.2 to 0.3. #978
  • #[pyproto] is re-implemented without specialization. #961
  • PyClassAlloc::alloc is renamed to PyClassAlloc::new. #990
  • #[pyproto] methods can now have return value T or PyResult<T> (previously only PyResult<T> was supported). #996
  • #[pyproto] methods can now skip annotating the return type if it is (). #998

Removed

  • Remove ManagedPyRef (unused, and needs specialization) #930

Fixed

  • Fix passing explicit None to Option<T> argument #[pyfunction] with a default value. #936
  • Fix PyClass.__new__'s not respecting subclasses when inherited by a Python class. #990
  • Fix returning Option<T> from #[pyproto] methods. #996
  • Fix accepting PyRef<Self> and PyRefMut<Self> to #[getter] and #[setter] methods. #999

PyO3 0.10.1

14 May 12:39
45cb26d
Compare
Choose a tag to compare

0.10.0 has a deadlock bug and was yanked. Thank you @davidhewitt for fixing it!

Fixed

  • Fix deadlock in Python::acquire_gil() after dropping a PyObject or Py<T>. #924

PyO3 0.10.0

13 May 04:39
7e4d1c4
Compare
Choose a tag to compare

Many changes but not so many API changes. See CHANGELOG and migraton guide for more.

Thank you @davidhewitt @m-ou-se @scalexm @Alexander-N @abingham @althonos @konstin @ijl @ArniDagur @oconnor663 and all issue reporters!

Added

  • Add FFI definition _PyDict_NewPresized. #849
  • Implement IntoPy<PyObject> for HashSet and BTreeSet. #864
  • Add PyAny::dir method. #886
  • Gate macros behind a macros feature (enabled by default). #897
  • Add ability to define class attributes using #[classattr] on functions in #[pymethods]. #905
  • Implement Clone for PyObject and Py<T>. #908
  • Implement Deref<Target = PyAny> for all builtin types. (PyList, PyTuple, PyDict etc.) #911
  • Implement Deref<Target = PyAny> for PyCell<T>. #911
  • Add #[classattr] support for associated constants in #[pymethods]. #914

Changed

  • Panics will now be raised as a Python PanicException. #797
  • Change PyObject and Py<T> reference counts to decrement immediately upon drop when the GIL is held. #851
  • Allow PyIterProtocol methods to use either PyRef or PyRefMut as the receiver type. #856
  • Change the implementation of FromPyObject for Py<T> to apply to a wider range of T, including all T: PyClass. #880
  • Move all methods from the ObjectProtocol trait to the PyAny struct. #911
  • Remove need for #![feature(specialization)] in crates depending on PyO3. #917

Removed

  • Remove PyMethodsProtocol trait. #889
  • Remove num-traits dependency. #895
  • Remove ObjectProtocol trait. #911
  • Remove PyAny::None. Users should use Python::None instead. #911
  • Remove all *ProtocolImpl traits. #917

Fixed

  • Fix support for __radd__ and other __r*__ methods as implementations for Python mathematical operators. #839
  • Fix panics during garbage collection when traversing objects that were already mutably borrowed. #855
  • Prevent &'static references to Python objects as arguments to #[pyfunction] and #[pymethods]. #869
  • Fix lifetime safety bug with AsPyRef::as_ref. #876
  • Fix #[pyo3(get)] attribute on Py<T> fields. #880
  • Fix segmentation faults caused by functions such as PyList::get_item returning borrowed objects when it was not safe to do so. #890
  • Fix segmentation faults caused by nested Python::acquire_gil calls creating dangling references. #893
  • Fix segmentatation faults when a panic occurs during a call to Python::allow_threads. #912

PyO3 0.9.2

09 Apr 08:16
Compare
Choose a tag to compare

Added

  • FromPyObject implementations for HashSet and BTreeSet. #842

Fixed

  • Correctly detect 32bit architecture. #830

PyO3 0.9.1

23 Mar 13:30
1c1d3c4
Compare
Choose a tag to compare

Fixed

  • Error messages for #[pyclass]. #826
  • FromPyObject implementation for PySequence. #827

PyO3 0.9.0

19 Mar 06:21
d43a349
Compare
Choose a tag to compare

This is a big release and there are some breaking changes.
Please check the migration guide.

Thank you @ijl @birkenfeld @Alexander-N @davidhewitt @konstin @c410-f3r @oconnor663 @andrewwhitehead @synapticarbors @bmatthieu3 @Hywan @paddywwoof @gilescope for contributing!
And thank you all bug reporters and reviewers, though it's difficult to list them here.

Changed

  • #[new] does not take PyRawObject and can return Self. #683
  • The blanket implementations for FromPyObject for &T and &mut T are no longer specializable. Implement PyTryFrom for your type to control the behavior of FromPyObject::extract() for your types. #713
  • The implementation for IntoPy<U> for T where U: FromPy<T> is no longer specializable. Control the behavior of this via the implementation of FromPy. #713
  • Use parking_lot::Mutex instead of spin::Mutex. #734
  • Bumped minimum Rust version to 1.42.0-nightly 2020-01-21. #761
  • PyRef and PyRefMut are renewed for PyCell. #770
  • Some new FFI functions for Python 3.8. #784
  • PyAny is now on the top level module and prelude. #816

Added

  • PyCell, which has RefCell-like features. #770
  • PyClass, PyLayout, PyClassInitializer. #683
  • Implemented IntoIterator for PySet and PyFrozenSet. #716
  • FromPyObject is now automatically implemented for T: Clone pyclasses. #730
  • #[pyo3(get)] and #[pyo3(set)] will now use the Rust doc-comment from the field for the Python property. #755
  • #[setter] functions may now take an argument of Pyo3::Python. #760
  • PyTypeInfo::BaseLayout and PyClass::BaseNativeType. #770
  • PyDowncastImpl. #770
  • Implement FromPyObject and IntoPy<PyObject> traits for arrays (up to 32). #778
  • migration.md and types.md in the guide. #795, #802
  • ffi::{_PyBytes_Resize, _PyDict_Next, _PyDict_Contains, _PyDict_GetDictPtr}. #820

Fixed

  • Fixed unsoundness of subclassing. #683.
  • Clear error indicator when the exception is handled on the Rust side. #719
  • Usage of raw identifiers with #[pyo3(set)]. #745
  • Usage of PyObject with #[pyo3(get)]. #760
  • #[pymethods] used in conjunction with #[cfg]. #769
  • "*" in a #[pyfunction()] argument list incorrectly accepting any number of positional arguments (use args = "*" when this behaviour is desired). #792
  • PyModule::dict. #809
  • Fix the case where DESCRIPTION is not null-terminated. #822

Removed

  • PyRawObject. #683
  • PyNoArgsFunction. #741
  • initialize_type(). To set the module name for a #[pyclass], use the module argument to the macro. #751
  • AsPyRef::as_mut/with/with_mut/into_py/into_mut_py. #770
  • PyTryFrom::try_from_mut/try_from_mut_exact/try_from_mut_unchecked. #770
  • Python::mut_from_owned_ptr/mut_from_borrowed_ptr. #770
  • ObjectProtocol::get_base/get_mut_base. #770