PyO3 v0.17.0 Release Notes

Release Date: 2022-08-23 // over 1 year ago
  • Packaging

    • ⚡️ Update inventory dependency to 0.3 (the multiple-pymethods feature now requires Rust 1.62 for correctness). #2492

    ➕ Added

    • ➕ Add timezone_utc. #1588
    • Implement ToPyObject for [T; N]. #2313
    • ➕ Add PyDictKeys, PyDictValues and PyDictItems Rust types. #2358
    • Add append_to_inittab. #2377
    • ➕ Add FFI definition PyFrame_GetCode. #2406
    • ➕ Add PyCode and PyFrame high level objects. #2408
    • Add FFI definitions Py_fstring_input, sendfunc, and _PyErr_StackItem. #2423
    • Add PyDateTime::new_with_fold, PyTime::new_with_fold, PyTime::get_fold, and PyDateTime::get_fold for PyPy. #2428
    • Accept #[pyo3(name)] on enum variants. #2457
    • Add CompareOp::matches to implement __richcmp__ as the result of a Rust std::cmp::Ordering comparison. #2460
    • ➕ Add PySuper type. #2486
    • 👌 Support PyPy on Windows with the generate-import-lib feature. #2506
    • Add FFI definitions Py_EnterRecursiveCall and Py_LeaveRecursiveCall. #2511
    • Add PyDict::get_item_with_error. #2536
    • ➕ Add #[pyclass(sequence)] option. #2567

    🔄 Changed

    • Change datetime constructors taking a tzinfo to take Option<&PyTzInfo> instead of Option<&PyObject>: PyDateTime::new, PyDateTime::new_with_fold, PyTime::new, and PyTime::new_with_fold. #1588
    • 🚚 Move PyTypeObject::type_object method to the PyTypeInfo trait, and deprecate the PyTypeObject trait. #2287
    • Methods of Py and PyAny now accept impl IntoPy<Py<PyString>> rather than just &str to allow use of the intern! macro. #2312
    • 🔄 Change the deprecated pyproto feature to be opt-in instead of opt-out. #2322
    • 👍 Emit better error messages when #[pyfunction] return types do not implement IntoPy. #2326
    • Require T: IntoPy for impl<T, const N: usize> IntoPy<PyObject> for [T; N] instead of T: ToPyObject. #2326
    • 🗄 Deprecate the ToBorrowedObject trait. #2333
    • Iterators over PySet and PyDict will now panic if the underlying collection is mutated during the iteration. #2380
    • Iterators over PySet and PyDict will now panic if the underlying collection is mutated during the iteration. #2380
    • 👍 Allow #[classattr] methods to be fallible. #2385
    • Prevent multiple #[pymethods] with the same name for a single #[pyclass]. #2399
    • Fixup lib_name when using PYO3_CONFIG_FILE. #2404
    • ➕ Add a message to the ValueError raised by the #[derive(FromPyObject)] implementation for a tuple struct. #2414
    • 👍 Allow #[classattr] methods to take Python argument. #2456
    • Rework PyCapsule type to resolve soundness issues: #2485
      • PyCapsule::new and PyCapsule::new_with_destructor now take name: Option<CString> instead of &CStr.
      • The destructor F in PyCapsule::new_with_destructor must now be Send.
      • PyCapsule::get_context deprecated in favour of PyCapsule::context which doesn't take a py: Python<'_> argument.
      • PyCapsule::set_context no longer takes a py: Python<'_> argument.
      • PyCapsule::name now returns PyResult<Option<&CStr>> instead of &CStr.
    • FromPyObject::extract for Vec<T> no longer accepts Python str inputs. #2500
    • Ensure each #[pymodule] is only initialized once. #2523
    • 🏗 pyo3_build_config::add_extension_module_link_args now also emits linker arguments for wasm32-unknown-emscripten. #2538
    • Type checks for PySequence and PyMapping now require inputs to inherit from (or register with) collections.abc.Sequence and collections.abc.Mapping respectively. #2477
    • 🏗 Disable PyFunction on when building for abi3 or PyPy. #2542
    • 🗄 Deprecate Python::acquire_gil. #2549

    ✂ Removed

    • ✂ Remove all functionality deprecated in PyO3 0.15. #2283
    • 👉 Make the Dict, WeakRef and BaseNativeType members of the PyClass private implementation details. #2572

    🛠 Fixed

    • Enable incorrectly disabled FFI definition PyThreadState_DeleteCurrent. #2357
    • 👀 Fix wrap_pymodule interactions with name resolution rules: it no longer "sees through" glob imports of use submodule::* when submodule::submodule is a #[pymodule]. #2363
    • Correct FFI definition PyEval_EvalCodeEx to take *const *mut PyObject array arguments instead of *mut *mut PyObject. #2368
    • 🛠 Fix "raw-ident" structs (e.g. #[pyclass] struct r#RawName) incorrectly having r# at the start of the class name created in Python. #2395
    • Correct FFI definition Py_tracefunc to be unsafe extern "C" fn (was previously safe). #2407
    • Fix compile failure with #[pyo3(from_py_with = "...")] annotations on a field in a #[derive(FromPyObject)] struct. #2414
    • Fix FFI definitions _PyDateTime_BaseTime and _PyDateTime_BaseDateTime lacking leading underscores in their names. #2421
    • ✂ Remove FFI definition PyArena on Python 3.10 and up. #2421
    • 🔋 Fix FFI definition PyCompilerFlags missing member cf_feature_version on Python 3.8 and up. #2423
    • 🛠 Fix FFI definition PyAsyncMethods missing member am_send on Python 3.10 and up. #2423
    • 🛠 Fix FFI definition PyGenObject having multiple incorrect members on various Python versions. #2423
    • Fix FFI definition PySyntaxErrorObject missing members end_lineno and end_offset on Python 3.10 and up. #2423
    • 🛠 Fix FFI definition PyHeapTypeObject missing member ht_module on Python 3.9 and up. #2423
    • 🛠 Fix FFI definition PyFrameObject having multiple incorrect members on various Python versions. #2424 #2434
    • 🛠 Fix FFI definition PyTypeObject missing deprecated field tp_print on Python 3.8. #2428
    • Fix FFI definitions PyDateTime_CAPI. PyDateTime_Date, PyASCIIObject, PyBaseExceptionObject, PyListObject, and PyTypeObject on PyPy. #2428
    • 🛠 Fix FFI definition _inittab field initfunc typo'd as initfun. #2431
    • Fix FFI definitions _PyDateTime_BaseTime and _PyDateTime_BaseDateTime incorrectly having fold member. #2432
    • 🛠 Fix FFI definitions PyTypeObject. PyHeapTypeObject, and PyCFunctionObject having incorrect members on PyPy 3.9. #2433
    • Fix FFI definition PyGetSetDef to have *const c_char for doc member (not *mut c_char). #2439
    • Fix #[pyo3(from_py_with = "...")] being ignored for 1-element tuple structs and transparent structs. #2440
    • 👉 Use memoffset to avoid UB when computing PyCell layout. #2450
    • 🛠 Fix incorrect enum names being returned by the generated repr for enums renamed by #[pyclass(name = "...")] #2457
    • 🛠 Fix PyObject_CallNoArgs incorrectly being available when building for abi3 on Python 3.9. #2476
    • 🛠 Fix several clippy warnings generated by #[pyfunction] arguments. #2503