From 93e1259108a072acb130e7243c17de57426b6028 Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Fri, 13 Sep 2024 13:53:16 +0100 Subject: [PATCH] release: 0.22.3 --- CHANGELOG.md | 37 ++++++++++++++++++- README.md | 4 +- examples/decorator/.template/pre-script.rhai | 2 +- .../maturin-starter/.template/pre-script.rhai | 2 +- examples/plugin/.template/pre-script.rhai | 2 +- .../.template/pre-script.rhai | 2 +- examples/word-count/.template/pre-script.rhai | 2 +- newsfragments/4328.fixed.md | 1 - newsfragments/4349.fixed.md | 1 - newsfragments/4355.added.md | 10 ----- newsfragments/4355.fixed.md | 2 - newsfragments/4359.fixed.md | 1 - newsfragments/4382.fixed.md | 1 - newsfragments/4396.fixed.md | 1 - newsfragments/4407.fixed.md | 1 - newsfragments/4410.added.md | 1 - newsfragments/4410.fixed.md | 3 -- newsfragments/4420.fixed.md | 1 - newsfragments/4420.removed.md | 1 - newsfragments/4445.added.md | 1 - newsfragments/4445.removed.md | 1 - newsfragments/4454.fixed.md | 1 - newsfragments/4456.changed.md | 1 - newsfragments/4461.added.md | 1 - newsfragments/4479.fixed.md | 1 - newsfragments/4481.changed.md | 1 - newsfragments/4511.added.md | 1 - 27 files changed, 43 insertions(+), 40 deletions(-) delete mode 100644 newsfragments/4328.fixed.md delete mode 100644 newsfragments/4349.fixed.md delete mode 100644 newsfragments/4355.added.md delete mode 100644 newsfragments/4355.fixed.md delete mode 100644 newsfragments/4359.fixed.md delete mode 100644 newsfragments/4382.fixed.md delete mode 100644 newsfragments/4396.fixed.md delete mode 100644 newsfragments/4407.fixed.md delete mode 100644 newsfragments/4410.added.md delete mode 100644 newsfragments/4410.fixed.md delete mode 100644 newsfragments/4420.fixed.md delete mode 100644 newsfragments/4420.removed.md delete mode 100644 newsfragments/4445.added.md delete mode 100644 newsfragments/4445.removed.md delete mode 100644 newsfragments/4454.fixed.md delete mode 100644 newsfragments/4456.changed.md delete mode 100644 newsfragments/4461.added.md delete mode 100644 newsfragments/4479.fixed.md delete mode 100644 newsfragments/4481.changed.md delete mode 100644 newsfragments/4511.added.md diff --git a/CHANGELOG.md b/CHANGELOG.md index caabd04129c..0c9afeed6df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,40 @@ To see unreleased changes, please see the [CHANGELOG on the main branch guide](h +## [0.22.3] - 2024-09-15 + +### Added + +- Add `pyo3::ffi::compat` namespace with compatibility shims for C API functions added in recent versions of Python. +- Add FFI definition `PyDict_GetItemRef` on Python 3.13 and newer, and `compat::PyDict_GetItemRef` for all versions. [#4355](https://github.com/PyO3/pyo3/pull/4355) +- Add FFI definition `PyList_GetItemRef` on Python 3.13 and newer, and `pyo3_ffi::compat::PyList_GetItemRef` for all versions. [#4410](https://github.com/PyO3/pyo3/pull/4410) +- Add FFI definitions `compat::Py_NewRef` and `compat::Py_XNewRef`. [#4445](https://github.com/PyO3/pyo3/pull/4445) +- Add FFI definitions `compat::PyObject_CallNoArgs` and `compat::PyObject_CallMethodNoArgs`. [#4461](https://github.com/PyO3/pyo3/pull/4461) +- Add `GilOnceCell>::clone_ref`. [#4511](https://github.com/PyO3/pyo3/pull/4511) + +### Changed + +- Improve error messages for `#[pyfunction]` defined inside `#[pymethods]`. [#4349](https://github.com/PyO3/pyo3/pull/4349) +- Improve performance of calls to Python by using the vectorcall calling convention where possible. [#4456](https://github.com/PyO3/pyo3/pull/4456) +- Mention the type name in the exception message when trying to instantiate a class with no constructor defined. [#4481](https://github.com/PyO3/pyo3/pull/4481) + +### Removed + +- Remove private FFI definition `_Py_PackageContext`. [#4420](https://github.com/PyO3/pyo3/pull/4420) + +### Fixed + +- Fix compile failure in declarative `#[pymodule]` under presence of `#![no_implicit_prelude]`. [#4328](https://github.com/PyO3/pyo3/pull/4328) +- Fix use of borrowed reference in `PyDict::get_item` (unsafe in free-threaded Python). [#4355](https://github.com/PyO3/pyo3/pull/4355) +- Fix `#[pyclass(eq)]` macro hygiene issues for structs and enums. [#4359](https://github.com/PyO3/pyo3/pull/4359) +- Fix hygiene/span issues of `'#[pyfunction]` and `#[pymethods]` generated code which affected expansion in `macro_rules` context. [#4382](https://github.com/PyO3/pyo3/pull/4382) +- Fix `unsafe_code` lint error in `#[pyclass]` generated code. [#4396](https://github.com/PyO3/pyo3/pull/4396) +- Fix async functions returning a tuple only returning the first element to Python. [#4407](https://github.com/PyO3/pyo3/pull/4407) +- Fix use of borrowed reference in `PyList::get_item` (unsafe in free-threaded Python). [#4410](https://github.com/PyO3/pyo3/pull/4410) +- Correct FFI definition `PyArg_ParseTupleAndKeywords` to take `*const *const c_char` instead of `*mut *mut c_char` on Python 3.13 and up. [#4420](https://github.com/PyO3/pyo3/pull/4420) +- Fix a soundness bug with `PyClassInitializer`: panic if adding subclass to existing instance via `PyClassInitializer::from(Py).add_subclass(SubClass)`. [#4454](https://github.com/PyO3/pyo3/pull/4454) +- Fix illegal reference counting op inside implementation of `__traverse__` handlers. [#4479](https://github.com/PyO3/pyo3/pull/4479) + ## [0.22.2] - 2024-07-17 ### Packaging @@ -1839,7 +1873,8 @@ Yanked - Initial release -[Unreleased]: https://github.com/pyo3/pyo3/compare/v0.22.2...HEAD +[Unreleased]: https://github.com/pyo3/pyo3/compare/v0.22.3...HEAD +[0.22.3]: https://github.com/pyo3/pyo3/compare/v0.22.2...v0.22.3 [0.22.2]: https://github.com/pyo3/pyo3/compare/v0.22.1...v0.22.2 [0.22.1]: https://github.com/pyo3/pyo3/compare/v0.22.0...v0.22.1 [0.22.0]: https://github.com/pyo3/pyo3/compare/v0.21.2...v0.22.0 diff --git a/README.md b/README.md index 0c20a6d08bc..28f9c0af0b6 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ name = "string_sum" crate-type = ["cdylib"] [dependencies] -pyo3 = { version = "0.22.2", features = ["extension-module"] } +pyo3 = { version = "0.22.3", features = ["extension-module"] } ``` **`src/lib.rs`** @@ -137,7 +137,7 @@ Start a new project with `cargo new` and add `pyo3` to the `Cargo.toml` like th ```toml [dependencies.pyo3] -version = "0.22.2" +version = "0.22.3" features = ["auto-initialize"] ``` diff --git a/examples/decorator/.template/pre-script.rhai b/examples/decorator/.template/pre-script.rhai index a9f0eb4a289..32b20a55d17 100644 --- a/examples/decorator/.template/pre-script.rhai +++ b/examples/decorator/.template/pre-script.rhai @@ -1,4 +1,4 @@ -variable::set("PYO3_VERSION", "0.22.2"); +variable::set("PYO3_VERSION", "0.22.3"); file::rename(".template/Cargo.toml", "Cargo.toml"); file::rename(".template/pyproject.toml", "pyproject.toml"); file::delete(".template"); diff --git a/examples/maturin-starter/.template/pre-script.rhai b/examples/maturin-starter/.template/pre-script.rhai index a9f0eb4a289..32b20a55d17 100644 --- a/examples/maturin-starter/.template/pre-script.rhai +++ b/examples/maturin-starter/.template/pre-script.rhai @@ -1,4 +1,4 @@ -variable::set("PYO3_VERSION", "0.22.2"); +variable::set("PYO3_VERSION", "0.22.3"); file::rename(".template/Cargo.toml", "Cargo.toml"); file::rename(".template/pyproject.toml", "pyproject.toml"); file::delete(".template"); diff --git a/examples/plugin/.template/pre-script.rhai b/examples/plugin/.template/pre-script.rhai index bbc96358a23..ee37346e10d 100644 --- a/examples/plugin/.template/pre-script.rhai +++ b/examples/plugin/.template/pre-script.rhai @@ -1,4 +1,4 @@ -variable::set("PYO3_VERSION", "0.22.2"); +variable::set("PYO3_VERSION", "0.22.3"); file::rename(".template/Cargo.toml", "Cargo.toml"); file::rename(".template/plugin_api/Cargo.toml", "plugin_api/Cargo.toml"); file::delete(".template"); diff --git a/examples/setuptools-rust-starter/.template/pre-script.rhai b/examples/setuptools-rust-starter/.template/pre-script.rhai index d28d9d09987..8ceb8df28bb 100644 --- a/examples/setuptools-rust-starter/.template/pre-script.rhai +++ b/examples/setuptools-rust-starter/.template/pre-script.rhai @@ -1,4 +1,4 @@ -variable::set("PYO3_VERSION", "0.22.2"); +variable::set("PYO3_VERSION", "0.22.3"); file::rename(".template/Cargo.toml", "Cargo.toml"); file::rename(".template/setup.cfg", "setup.cfg"); file::delete(".template"); diff --git a/examples/word-count/.template/pre-script.rhai b/examples/word-count/.template/pre-script.rhai index a9f0eb4a289..32b20a55d17 100644 --- a/examples/word-count/.template/pre-script.rhai +++ b/examples/word-count/.template/pre-script.rhai @@ -1,4 +1,4 @@ -variable::set("PYO3_VERSION", "0.22.2"); +variable::set("PYO3_VERSION", "0.22.3"); file::rename(".template/Cargo.toml", "Cargo.toml"); file::rename(".template/pyproject.toml", "pyproject.toml"); file::delete(".template"); diff --git a/newsfragments/4328.fixed.md b/newsfragments/4328.fixed.md deleted file mode 100644 index f21fdfbcb76..00000000000 --- a/newsfragments/4328.fixed.md +++ /dev/null @@ -1 +0,0 @@ -Fix compile failure in declarative `#[pymodule]` under presence of `#![no_implicit_prelude]`. diff --git a/newsfragments/4349.fixed.md b/newsfragments/4349.fixed.md deleted file mode 100644 index 0895ffa1ae1..00000000000 --- a/newsfragments/4349.fixed.md +++ /dev/null @@ -1 +0,0 @@ -Improve error messages for `#[pyfunction]` defined inside `#[pymethods]` diff --git a/newsfragments/4355.added.md b/newsfragments/4355.added.md deleted file mode 100644 index 1410c0720bf..00000000000 --- a/newsfragments/4355.added.md +++ /dev/null @@ -1,10 +0,0 @@ -* Added an `ffi::compat` namespace to store compatibility shims for C API - functions added in recent versions of Python. - -* Added bindings for `PyDict_GetItemRef` on Python 3.13 and newer. Also added - `ffi::compat::PyDict_GetItemRef` which re-exports the FFI binding on Python - 3.13 or newer and defines a compatibility version on older versions of - Python. This function is inherently safer to use than `PyDict_GetItem` and has - an API that is easier to use than `PyDict_GetItemWithError`. It returns a - strong reference to value, as opposed to the two older functions which return - a possibly unsafe borrowed reference. diff --git a/newsfragments/4355.fixed.md b/newsfragments/4355.fixed.md deleted file mode 100644 index 9a141bc6b96..00000000000 --- a/newsfragments/4355.fixed.md +++ /dev/null @@ -1,2 +0,0 @@ -Avoid creating temporary borrowed reference in dict.get_item bindings. Borrowed -references like this are unsafe in the free-threading build. diff --git a/newsfragments/4359.fixed.md b/newsfragments/4359.fixed.md deleted file mode 100644 index 7174cab0a9d..00000000000 --- a/newsfragments/4359.fixed.md +++ /dev/null @@ -1 +0,0 @@ -Fixed `pyclass` macro hygiene issues for structs and enums and added tests. \ No newline at end of file diff --git a/newsfragments/4382.fixed.md b/newsfragments/4382.fixed.md deleted file mode 100644 index 974ae23d3bf..00000000000 --- a/newsfragments/4382.fixed.md +++ /dev/null @@ -1 +0,0 @@ -Fixed hygiene/span issues of emitted code which affected expansion in `macro_rules` context. \ No newline at end of file diff --git a/newsfragments/4396.fixed.md b/newsfragments/4396.fixed.md deleted file mode 100644 index 285358ad526..00000000000 --- a/newsfragments/4396.fixed.md +++ /dev/null @@ -1 +0,0 @@ -Hide confusing warnings about unsafe usage in `#[pyclass]` implementation. diff --git a/newsfragments/4407.fixed.md b/newsfragments/4407.fixed.md deleted file mode 100644 index be2706bca05..00000000000 --- a/newsfragments/4407.fixed.md +++ /dev/null @@ -1 +0,0 @@ -Fix async functions returning a tuple only returning the first element to Python. diff --git a/newsfragments/4410.added.md b/newsfragments/4410.added.md deleted file mode 100644 index 350a54531bd..00000000000 --- a/newsfragments/4410.added.md +++ /dev/null @@ -1 +0,0 @@ -Add ffi binding `PyList_GetItemRef` and `pyo3_ffi::compat::PyList_GetItemRef` diff --git a/newsfragments/4410.fixed.md b/newsfragments/4410.fixed.md deleted file mode 100644 index f4403409aea..00000000000 --- a/newsfragments/4410.fixed.md +++ /dev/null @@ -1,3 +0,0 @@ -* Avoid creating temporary borrowed reference in list.get_item - bindings. Temporary borrowed references are unsafe in the free-threaded python - build if the list is shared between threads. diff --git a/newsfragments/4420.fixed.md b/newsfragments/4420.fixed.md deleted file mode 100644 index dec974555d9..00000000000 --- a/newsfragments/4420.fixed.md +++ /dev/null @@ -1 +0,0 @@ -Correct FFI definition `PyArg_ParseTupleAndKeywords` to take `*const *const c_char` instead of `*mut *mut c_char` on Python 3.13 and up. diff --git a/newsfragments/4420.removed.md b/newsfragments/4420.removed.md deleted file mode 100644 index 9d17c33e143..00000000000 --- a/newsfragments/4420.removed.md +++ /dev/null @@ -1 +0,0 @@ -Remove FFI definition of private variable `_Py_PackageContext`. diff --git a/newsfragments/4445.added.md b/newsfragments/4445.added.md deleted file mode 100644 index ee6af52d97e..00000000000 --- a/newsfragments/4445.added.md +++ /dev/null @@ -1 +0,0 @@ -Add FFI definitions `compat::Py_NewRef` and `compat::Py_XNewRef`. diff --git a/newsfragments/4445.removed.md b/newsfragments/4445.removed.md deleted file mode 100644 index b5b7e450331..00000000000 --- a/newsfragments/4445.removed.md +++ /dev/null @@ -1 +0,0 @@ -Remove private FFI definitions `_Py_NewRef` and `_Py_XNewRef`. diff --git a/newsfragments/4454.fixed.md b/newsfragments/4454.fixed.md deleted file mode 100644 index e7faf3e690d..00000000000 --- a/newsfragments/4454.fixed.md +++ /dev/null @@ -1 +0,0 @@ -Fix a soundness bug with `PyClassInitializer`: from now you cannot initialize a `PyClassInitializer` with `PyClassInitializer::from(Py).add_subclass(SubClass)`. \ No newline at end of file diff --git a/newsfragments/4456.changed.md b/newsfragments/4456.changed.md deleted file mode 100644 index 094dece12a5..00000000000 --- a/newsfragments/4456.changed.md +++ /dev/null @@ -1 +0,0 @@ -Improve performance of calls to Python by using the vectorcall calling convention where possible. \ No newline at end of file diff --git a/newsfragments/4461.added.md b/newsfragments/4461.added.md deleted file mode 100644 index c151664c843..00000000000 --- a/newsfragments/4461.added.md +++ /dev/null @@ -1 +0,0 @@ -Add FFI definitions `compat::PyObject_CallNoArgs` and `compat::PyObject_CallMethodNoArgs`. diff --git a/newsfragments/4479.fixed.md b/newsfragments/4479.fixed.md deleted file mode 100644 index 15d634543af..00000000000 --- a/newsfragments/4479.fixed.md +++ /dev/null @@ -1 +0,0 @@ -Remove illegal reference counting op inside implementation of `__traverse__` handlers. diff --git a/newsfragments/4481.changed.md b/newsfragments/4481.changed.md deleted file mode 100644 index 9ce455c923c..00000000000 --- a/newsfragments/4481.changed.md +++ /dev/null @@ -1 +0,0 @@ -Mention the type name in the exception message when trying to instantiate a class with no constructor defined. diff --git a/newsfragments/4511.added.md b/newsfragments/4511.added.md deleted file mode 100644 index 6572ddc7238..00000000000 --- a/newsfragments/4511.added.md +++ /dev/null @@ -1 +0,0 @@ -Add Python-ref cloning `clone_ref` for `GILOnceCell>`