Skip to content

Releases: PyO3/pyo3

PyO3 0.9.0 alpha.1

18 Jan 06:12
d2174c2
Compare
Choose a tag to compare
PyO3 0.9.0 alpha.1 Pre-release
Pre-release

PyO3 0.9.0 Alpha.1

There are some breaking changes...
But I believe in most cases, you just change this

impl MyClass {
    #[new] 
    fn new(init: &PyRawObject) { 
        init.init(MyClass {});
    }
}

to

impl MyClass {
    #[new]
    fn new() -> Self { 
        MyClass {}
    }
}

and everything works fine.

Please read the guide for detail.

CHANGELOG

Changed

  • 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.
  • 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.
  • #[new] does not take PyRawObject and can reutrn Self #683
  • Use parking_lot::Mutex instead of spin::Mutex #734

Added

  • Implemented IntoIterator for PySet and PyFrozenSet. #716
  • PyClass, PyClassShell, PyObjectLayout, PyClassInitializer #683

Fixed

  • Clear error indicator when the exception is handled on the Rust side. #719
  • Fixed unsoundness of subclassing. #683.

Removed

  • PyRef, PyRefMut, PyRawObject #683

PyO3 0.8.5

05 Jan 10:08
7e591e3
Compare
Choose a tag to compare

Added

  • Support for #[name = "foo"] attribute for #[pyfunction] and in #[pymethods]. #692
  • Implemented FromPyObject for HashMap and BTreeMap

PyO3 0.8.4

14 Dec 13:33
4aa2ff5
Compare
Choose a tag to compare

Added

  • Support for #[text_signature] attribute. #675

PyO3 0.8.3

23 Nov 11:15
42ee180
Compare
Choose a tag to compare

[0.8.3]

Fixed

  • Now all &Py~ types have !Send bound. #655
  • Fix a compile error raised by the stabilization of ! type. #672.

Removed

  • #[init] is removed. #658

PyO3 0.8.2

27 Oct 06:11
fe22975
Compare
Choose a tag to compare

Added

  • FFI compatibility for PEP 590 Vectorcall. #641

Fixed

  • Fix PySequenceProtocol::set_item. #624
  • Fix a corner case of BigInt::FromPyObject. #630
  • Fix index errors in parameter conversion. #631
  • Fix handling of invalid utf-8 sequences in PyString::as_bytes. #639
    and PyString::to_string_lossy #642.
  • Remove __contains__ and __iter__ from PyMappingProtocol. #644
  • Fix proc-macro definition of PySetAttrProtocol. #645

PyO3 0.8.1

08 Oct 02:56
89b7c7e
Compare
Choose a tag to compare

NOTE Please take care that PyO3 <= 0.8.0 doesn't support the latest nightly (See #614 for detail).

Added

Fixed

  • Make sure the right Python interpreter is used in OSX builds. #604
  • Patch specialization being broken by Rust 1.40. #614
  • Fix a segfault around PyErr. #597

PyO3 0.8.0

16 Sep 11:07
88b0a03
Compare
Choose a tag to compare

Added

  • module argument to pyclass macro. #499
  • py_run! macro #512
  • Use existing fields and methods before calling custom getattr. #505
  • PyBytes can now be indexed just like Vec<u8>
  • Implement IntoPy<PyObject> for PyRef and PyRefMut.

Removed

  • IntoPyObject was replaced with IntoPy<PyObject>
  • #[pyclass(subclass)] is hidden a unsound-subclass feature because it's causing segmentation faults.

Fixed

  • More readable error message for generics in pyclass #503

Changed

  • Implementing the Using the gc parameter for pyclass (e.g. #[pyclass(gc)]) without implementing the class::PyGCProtocol trait is now a compile-time error. Failing to implement this trait could lead to segfaults. #532
  • PyByteArray::data has been replaced with PyDataArray::to_vec because returning a &[u8] is unsound. (See this comment for a great write-up for why that was unsound)
  • Replace mashup with paste.
  • GILPool gained a Python marker to prevent it from being misused to release Python objects without the GIL held.

PyO3 0.7.0

26 May 09:07
ed52d57
Compare
Choose a tag to compare

Added

  • PyPy support by omerbenamram in #393
  • Have PyModule generate an index of its members (__all__ list).
  • Allow slf: PyRef<T> for pyclass(#419)
  • Allow to use lifetime specifiers in pymethods
  • Add marshal module. #460

Changed

  • Python::run returns PyResult<()> instead of PyResult<&PyAny>.
  • Methods decorated with #[getter] and #[setter] can now omit wrapping the
    result type in PyResult if they don't raise exceptions.

Fixed

  • type_object::PyTypeObject has been marked unsafe because breaking the contract type_object::PyTypeObject::init_type can lead to UB.
  • Fixed automatic derive of PySequenceProtocol implementation in #423.
  • Capitalization & better wording to README.md.
  • Docstrings of properties is now properly set using the doc of the #[getter] method.
  • Fixed issues with pymethods crashing on doc comments containing double quotes.
  • PySet::new and PyFrozenSet::new now return PyResult<&Py[Frozen]Set>; exceptions are raised if
    the items are not hashable.
  • Fixed building using venv on Windows.
  • PyTuple::new now returns &PyTuple instead of Py<PyTuple>.

PyO3 v0.6.0

28 Mar 11:57
Compare
Choose a tag to compare

Regressions

  • Currently, #341 causes cargo test to fail with weird linking errors when the extension-module feature is activated. For now you can work around this by making the extension-module feature optional and running the tests with cargo test --no-default-features:
[dependencies.pyo3]
version = "0.6.0"

[features]
extension-module = ["pyo3/extension-module"]
default = ["extension-module"]

Added

  • Added a wrap_pymodule! macro similar to the existing wrap_pyfunction! macro. Only available on python 3
  • Added support for cross compiling (e.g. to arm v7) by mtp401 in #327. See the "Cross Compiling" section in the "Building and Distribution" chapter of the guide for more details.
  • The PyRef and PyRefMut types, which allow to differentiate between an instance of a rust struct on the rust heap and an instance that is embedded inside a python object. By kngwyu in #335
  • Added FromPy<T> and IntoPy<T> which are equivalent to From<T> and Into<T> except that they require a gil token.
  • Added ManagedPyRef, which should eventually replace ToBorrowedObject.

Changed

  • Renamed PyObjectRef to PyAny in #388
  • Renamed add_function to add_wrapped as it now also supports modules.
  • Renamed #[pymodinit] to #[pymodule]
  • py.init(|| value) becomes Py::new(value)
  • py.init_ref(|| value) becomes PyRef::new(value)
  • py.init_mut(|| value) becomes PyRefMut::new(value).
  • PyRawObject::init is now infallible, e.g. it returns () instead of PyResult<()>.
  • Renamed py_exception! to create_exception! and refactored the error macros.
  • Renamed wrap_function! to wrap_pyfunction!
  • Renamed #[prop(get, set)] to #[pyo3(get, set)]
  • #[pyfunction] now supports the same arguments as #[pyfn()]
  • Some macros now emit proper spanned errors instead of panics.
  • Migrated to the 2018 edition
  • crate::types::exceptions moved to crate::exceptions
  • Replace IntoPyTuple with IntoPy<Py<PyTuple>>.
  • IntoPyPointer and ToPyPointer moved into the crate root.
  • class::CompareOp moved into class::basic::CompareOp
  • PyTypeObject is now a direct subtrait PyTypeCreate, removing the old cyclical implementation in #350
  • Add PyList::{sort, reverse} by chr1sj0nes in #357 and #358
  • Renamed the typeob module to type_object

Removed

  • PyToken was removed due to unsoundness (See #94).
  • Removed the unnecessary type parameter from PyObjectAlloc
  • NoArgs. Just use an empty tuple
  • PyObjectWithGIL. PyNativeType is sufficient now that PyToken is removed.

Fixed

  • A soudness hole where every instances of a #[pyclass] struct was considered to be part of a python object, even though you can create instances that are not part of the python heap. This was fixed through PyRef and PyRefMut.
  • Fix kwargs support in #328.
  • Add full support for __dict__ in #403.

PyO3 v0.5.3

04 Jan 10:35
Compare
Choose a tag to compare

Fixed

  • Fix memory leak in ArrayList by kngwyu #316