PyO3 v0.14.0 Release Notes

Release Date: 2021-07-03 // almost 3 years ago
  • Packaging

    • ⚡️ Update num-bigint optional dependency to 0.4. #1481
    • ⚡️ Update num-complex optional dependency to 0.4. #1482
    • 👍 Extend hashbrown optional dependency supported versions to include 0.11. #1496
    • 👌 Support PyPy 3.7. #1538

    ➕ Added

    • Extend conversions for [T; N] to all N using const generics (on Rust 1.51 and up). #1128
    • ➕ Add conversions between OsStr/ OsString and Python strings. #1379
    • ➕ Add conversions between Path/ PathBuf and Python strings (and pathlib.Path objects). #1379 #1654
    • ➕ Add a new set of #[pyo3(...)] attributes to control various PyO3 macro functionality:
      • #[pyo3(from_py_with = "...")] function arguments and struct fields to override the default from-Python conversion. #1411
      • #[pyo3(name = "...")] for setting Python names. #1567
      • #[pyo3(text_signature = "...")] for setting text signature. #1658
    • ➕ Add FFI definition PyCFunction_CheckExact for Python 3.9 and later. #1425
    • Add FFI definition Py_IS_TYPE. #1429
    • Add FFI definition _Py_InitializeMain. #1473
    • ➕ Add FFI definitions from cpython/import.h.#1475
    • ➕ Add tuple and unit struct support for #[pyclass] macro. #1504
    • Add FFI definition PyDateTime_TimeZone_UTC. #1572
    • ➕ Add support for #[pyclass(extends=Exception)]. #1591
    • ➕ Add PyErr::cause and PyErr::set_cause. #1679
    • ➕ Add FFI definitions from cpython/pystate.h. #1687
    • ➕ Add wrap_pyfunction! macro to pyo3::prelude. #1695

    🔄 Changed

    • 👍 Allow only one #[pymethods] block per #[pyclass] by default, to remove the dependency on inventory. Add a multiple-pymethods feature to opt-in the original behavior and dependency on inventory. #1457
    • 🔄 Change PyTimeAccess::get_fold to return a bool instead of a u8. #1397
    • 🗄 Deprecate FFI definition PyCFunction_Call for Python 3.9 and up. #1425
    • 🗄 Deprecate FFI definition PyModule_GetFilename. #1425
    • 0️⃣ The auto-initialize feature is no longer enabled by default. #1443
    • Change PyCFunction::new() and PyCFunction::new_with_keywords() to take &'static str arguments rather than implicitly copying (and leaking) them. #1450
    • 🗄 Deprecate PyModule::call, PyModule::call0, PyModule::call1 and PyModule::get. #1492
    • Add length information to PyBufferErrors raised from PyBuffer::copy_to_slice and PyBuffer::copy_from_slice. #1534
    • 🍎 Automatically set -undefined and dynamic_lookup linker arguments on macOS with the extension-module feature. #1539
    • 🗄 Deprecate #[pyproto] methods which are easier to implement as #[pymethods]: #1560
      • PyBasicProtocol::__bytes__ and PyBasicProtocol::__format__
      • PyContextProtocol::__enter__ and PyContextProtocol::__exit__
      • PyDescrProtocol::__delete__ and PyDescrProtocol::__set_name__
      • PyMappingProtocol::__reversed__
      • PyNumberProtocol::__complex__ and PyNumberProtocol::__round__
      • PyAsyncProtocol::__aenter__ and PyAsyncProtocol::__aexit__
    • 🗄 Deprecate several attributes in favor of the new #[pyo3(...)] options:
      • #[name = "..."], replaced by #[pyo3(name = "...")] #1567
      • #[pyfn(m, "name")], replaced by #[pyfn(m)] #[pyo3(name = "...")]. #1610
      • #[pymodule(name)], replaced by #[pymodule] #[pyo3(name = "...")] #1650
      • #[text_signature = "..."], replaced by #[pyo3(text_signature = "...")]. #1658
    • ⬇️ Reduce LLVM line counts to improve compilation times. #1604
    • No longer call PyEval_InitThreads in #[pymodule] init code. #1630
    • 🐎 Use METH_FASTCALL argument passing convention, when possible, to improve #[pyfunction] and method performance. #1619, #1660
    • Filter sysconfigdata candidates by architecture when cross-compiling. #1626

    ✂ Removed

    • ✂ Remove deprecated exception names BaseException etc. #1426
    • Remove deprecated methods Python::is_instance, Python::is_subclass, Python::release, Python::xdecref, and Py::from_owned_ptr_or_panic. #1426
    • ✂ Remove many FFI definitions which never existed in the Python C-API:
      • (previously deprecated) PyGetSetDef_INIT, PyGetSetDef_DICT, PyCoro_Check, PyCoroWrapper_Check, and PyAsyncGen_Check #1426
      • PyMethodDef_INIT #1426
      • PyTypeObject_INIT #1429
      • PyObject_Check, PySuper_Check, and FreeFunc #1438
      • PyModuleDef_INIT #1630
    • ✂ Remove pyclass implementation details from PyTypeInfo:
      • Type, DESCRIPTION, and FLAGS #1456
      • BaseType, BaseLayout, Layout, Initializer #1596
    • Remove PYO3_CROSS_INCLUDE_DIR environment variable and the associated C header parsing functionality. #1521
    • ✂ Remove raw_pycfunction! macro. #1619
    • ✂ Remove PyClassAlloc trait. #1657
    • Remove PyList::get_parked_item. #1664

    🛠 Fixed

    • ✂ Remove FFI definition PyCFunction_ClearFreeList for Python 3.9 and later. #1425
    • PYO3_CROSS_LIB_DIR enviroment variable no long required when compiling for x86-64 Python from macOS arm64 and reverse. #1428
    • Fix FFI definition _PyEval_RequestCodeExtraIndex, which took an argument of the wrong type. #1429
    • 🛠 Fix FFI definition PyIndex_Check missing with the abi3 feature. #1436
    • 🛠 Fix incorrect TypeError raised when keyword-only argument passed along with a positional argument in *args. #1440
    • 🛠 Fix inability to use a named lifetime for &PyTuple of *args in #[pyfunction]. #1440
    • 🛠 Fix use of Python argument for #[pymethods] inside macro expansions. #1505
    • No longer include __doc__ in __all__ generated for #[pymodule]. #1509
    • 🔧 Always use cross-compiling configuration if any of the PYO3_CROSS family of environment variables are set. #1514
    • 👌 Support EnvironmentError, IOError, and WindowsError on PyPy. #1533
    • 🛠 Fix unneccessary rebuilds when cycling between cargo check and cargo clippy in a Python virtualenv. #1557
    • 🛠 Fix segfault when dereferencing ffi::PyDateTimeAPI without the GIL. #1563
    • 🛠 Fix memory leak in FromPyObject implementations for u128 and i128. #1638
    • 🛠 Fix #[pyclass(extends=PyDict)] leaking the dict contents on drop. #1657
    • 🛠 Fix segfault when calling PyList::get_item with negative indices. #1668
    • Fix FFI definitions of PyEval_SetProfile/PyEval_SetTrace to take Option<Py_tracefunc> parameters. #1692
    • 🛠 Fix ToPyObject impl for HashSet to accept non-default hashers. #1702