PyO3 v0.15.0 Release Notes

Release Date: 2021-11-03 // over 2 years ago
  • Packaging

    • pyo3's Cargo.toml now advertises links = "python" to inform Cargo that it links against libpython. #1819
    • โž• Added optional anyhow feature to convert anyhow::Error into PyErr. #1822
    • ๐Ÿ‘Œ Support Python 3.10. #1889
    • โž• Added optional eyre feature to convert eyre::Report into PyErr. #1893
    • ๐Ÿ‘Œ Support PyPy 3.8. #1948

    โž• Added

    • Add PyList::get_item_unchecked and PyTuple::get_item_unchecked to get items without bounds checks. #1733
    • ๐Ÿ‘Œ Support #[doc = include_str!(...)] attributes on Rust 1.54 and up. #1746
    • โž• Add PyAny::py as a convenience for PyNativeType::py. #1751
    • โž• Add implementation of std::ops::Index<usize> for PyList, PyTuple and PySequence. #1825
    • โž• Add range indexing implementations of std::ops::Index for PyList, PyTuple and PySequence. #1829
    • โž• Add PyMapping type to represent the Python mapping protocol. #1844
    • โž• Add commonly-used sequence methods to PyList and PyTuple. #1849
    • โž• Add as_sequence methods to PyList and PyTuple. #1860
    • โž• Add support for magic methods in #[pymethods], intended as a replacement for #[pyproto]. #1864
    • โž• Add abi3-py310 feature. #1889
    • โž• Add PyCFunction::new_closure to create a Python function from a Rust closure. #1901
    • โž• Add support for positional-only arguments in #[pyfunction]. #1925
    • โž• Add PyErr::take to attempt to fetch a Python exception if present. #1957

    ๐Ÿ”„ Changed

    • PyList, PyTuple and PySequence's APIs now accepts only usize indices instead of isize. #1733, #1802, #1803
    • PyList::get_item and PyTuple::get_item now return PyResult<&PyAny> instead of panicking. #1733
    • PySequence::in_place_repeat and PySequence::in_place_concat now return PyResult<&PySequence> instead of PyResult<()>, which is needed in case of immutable sequences such as tuples. #1803
    • PySequence::get_slice now returns PyResult<&PySequence> instead of PyResult<&PyAny>. #1829
    • ๐Ÿ—„ Deprecate PyTuple::split_from. #1804
    • ๐Ÿ—„ Deprecate PyTuple::slice, new method PyTuple::get_slice added with usize indices. #1828
    • ๐Ÿ“œ Deprecate FFI definitions PyParser_SimpleParseStringFlags, PyParser_SimpleParseStringFlagsFilename, PyParser_SimpleParseFileFlags when building for Python 3.9. #1830
    • ๐Ÿ“œ Mark FFI definitions removed in Python 3.10 PyParser_ASTFromString, PyParser_ASTFromStringObject, PyParser_ASTFromFile, PyParser_ASTFromFileObject, PyParser_SimpleParseStringFlags, PyParser_SimpleParseStringFlagsFilename, PyParser_SimpleParseFileFlags, PyParser_SimpleParseString, PyParser_SimpleParseFile, Py_SymtableString, and Py_SymtableStringObject. #1830
    • ๐Ÿ—„ #[pymethods] now handles magic methods similarly to #[pyproto]. In the future, #[pyproto] may be deprecated. #1864
    • โž• Deprecate FFI definitions PySys_AddWarnOption, PySys_AddWarnOptionUnicode and PySys_HasWarnOptions. #1887
    • Deprecate #[call] attribute in favor of using fn __call__. #1929
    • Fix missing FFI definition _PyImport_FindExtensionObject on Python 3.10. #1942
    • ๐Ÿ”„ Change PyErr::fetch to panic in debug mode if no exception is present. #1957

    ๐Ÿ›  Fixed

    • ๐Ÿ›  Fix building with a conda environment on Windows. #1873
    • ๐Ÿ›  Fix panic on Python 3.6 when calling Python::with_gil with Python initialized but threading not initialized. #1874
    • ๐Ÿ›  Fix incorrect linking to version-specific DLL instead of python3.dll when cross-compiling to Windows with abi3. #1880
    • ๐Ÿ›  Fix FFI definition for PyTuple_ClearFreeList incorrectly being present for Python 3.9 and up. #1887
    • ๐Ÿ›  Fix panic in generated #[derive(FromPyObject)] for enums. #1888
    • ๐Ÿ›  Fix cross-compiling to Python 3.7 builds with the "m" abi flag. #1908
    • Fix __mod__ magic method fallback to __rmod__. #1934.
    • Fix missing FFI definition _PyImport_FindExtensionObject on Python 3.10. #1942