release: 0.19.0

This commit is contained in:
David Hewitt 2023-05-28 22:47:00 +01:00
parent c7dd2e3cd7
commit 2500e22e13
40 changed files with 84 additions and 45 deletions

View File

@ -10,6 +10,48 @@ To see unreleased changes, please see the [CHANGELOG on the main branch guide](h
<!-- towncrier release notes start -->
## [0.19.0] - 2023-05-31
### Packaging
- Correct dependency on syn to version 1.0.85 instead of the incorrect version 1.0.56. [#3152](https://github.com/PyO3/pyo3/pull/3152)
### Added
- Accept `text_signature` option (and automatically generate signature) for `#[new]` in `#[pymethods]`. [#2980](https://github.com/PyO3/pyo3/pull/2980)
- Add support for converting to and from Python's `decimal.Decimal` and `rust_decimal::Decimal`. [#3016](https://github.com/PyO3/pyo3/pull/3016)
- Add `#[pyo3(from_item_all)]` when deriving `FromPyObject` to specify `get_item` as getter for all fields. [#3120](https://github.com/PyO3/pyo3/pull/3120)
- Add `pyo3::exceptions::PyBaseExceptionGroup` for Python 3.11, and corresponding FFI definition `PyExc_BaseExceptionGroup`. [#3141](https://github.com/PyO3/pyo3/pull/3141)
- Accept `#[new]` with `#[classmethod]` to create a constructor which receives a (subtype's) class/`PyType` as its first argument. [#3157](https://github.com/PyO3/pyo3/pull/3157)
- Add `PyClass::get` and `Py::get` for GIL-indepedent access to classes with `#[pyclass(frozen)]`. [#3158](https://github.com/PyO3/pyo3/pull/3158)
- Add `PyAny::is_exact_instance` and `PyAny::is_exact_instance_of`. [#3161](https://github.com/PyO3/pyo3/pull/3161)
### Changed
- `PyAny::is_instance_of::<T>(obj)` is now equivalent to `T::is_type_of(obj)`, and now returns `bool` instead of `PyResult<bool>`. [#2881](https://github.com/PyO3/pyo3/pull/2881)
- Deprecate `text_signature` option on `#[pyclass]` structs. [#2980](https://github.com/PyO3/pyo3/pull/2980)
- No longer wrap `anyhow::Error`/`eyre::Report` containing a basic `PyErr` without a chain in a `PyRuntimeError`. [#3004](https://github.com/PyO3/pyo3/pull/3004)
- - Change `#[getter]` and `#[setter]` to use a common call "trampoline" to slightly reduce generated code size and compile times. [#3029](https://github.com/PyO3/pyo3/pull/3029)
- Improve default values for str, numbers and bool in automatically-generated `text_signature`. [#3050](https://github.com/PyO3/pyo3/pull/3050)
- Improve default value for `None` in automatically-generated `text_signature`. [#3066](https://github.com/PyO3/pyo3/pull/3066)
- Rename `PySequence::list` and `PySequence::tuple` to `PySequence::to_list` and `PySequence::to_tuple`. (The old names continue to exist as deprecated forms.) [#3111](https://github.com/PyO3/pyo3/pull/3111)
- Extend the lifetime of the GIL token returned by `PyRef::py` and `PyRefMut::py` to match the underlying borrow. [#3131](https://github.com/PyO3/pyo3/pull/3131)
- Safe access to the GIL, for example via `Python::with_gil`, is now locked inside of implementations of the `__traverse__` slot. [#3168](https://github.com/PyO3/pyo3/pull/3168)
### Removed
- Remove all functionality deprecated in PyO3 0.17, most prominently `Python::acquire_gil` is replaced by `Python::with_gil`. [#2981](https://github.com/PyO3/pyo3/pull/2981)
### Fixed
- Correct FFI definitions `PyGetSetDef`, `PyMemberDef`, `PyStructSequence_Field` and `PyStructSequence_Desc` to have `*const c_char` members for `name` and `doc` (not `*mut c_char`). [#3036](https://github.com/PyO3/pyo3/pull/3036)
- Fix panic on `fmt::Display`, instead return `"<unprintable object>"` string and report error via `sys.unraisablehook()` [#3062](https://github.com/PyO3/pyo3/pull/3062)
- Fix a compile error of "temporary value dropped while borrowed" when `#[pyfunction]`s take references into `#[pyclass]`es [#3142](https://github.com/PyO3/pyo3/pull/3142)
- Fix crashes caused by PyO3 applying deferred reference count updates when entering a `__traverse__` implementation. [#3168](https://github.com/PyO3/pyo3/pull/3168)
- Forbid running the `Drop` implementations of unsendable classes on other threads. [#3176](https://github.com/PyO3/pyo3/pull/3176)
- Fix a compile error when `#[pymethods]` items come from somewhere else (for example, as a macro argument) and a custom receiver like `Py<Self>` is used. [#3178](https://github.com/PyO3/pyo3/pull/3178)
## [0.18.3] - 2023-04-13
### Added
@ -1436,7 +1478,8 @@ Yanked
- Initial release
[Unreleased]: https://github.com/pyo3/pyo3/compare/v0.18.3...HEAD
[Unreleased]: https://github.com/pyo3/pyo3/compare/v0.19.0...HEAD
[0.19.0]: https://github.com/pyo3/pyo3/compare/v0.18.3...v0.19.0
[0.18.3]: https://github.com/pyo3/pyo3/compare/v0.18.2...v0.18.3
[0.18.2]: https://github.com/pyo3/pyo3/compare/v0.18.1...v0.18.2
[0.18.1]: https://github.com/pyo3/pyo3/compare/v0.18.0...v0.18.1

View File

@ -1,6 +1,6 @@
[package]
name = "pyo3"
version = "0.18.3"
version = "0.19.0"
description = "Bindings to Python interpreter"
authors = ["PyO3 Project and Contributors <https://github.com/PyO3>"]
readme = "README.md"
@ -20,10 +20,10 @@ parking_lot = ">= 0.11, < 0.13"
memoffset = "0.9"
# ffi bindings to the python interpreter, split into a separate crate so they can be used independently
pyo3-ffi = { path = "pyo3-ffi", version = "=0.18.3" }
pyo3-ffi = { path = "pyo3-ffi", version = "=0.19.0" }
# support crates for macros feature
pyo3-macros = { path = "pyo3-macros", version = "=0.18.3", optional = true }
pyo3-macros = { path = "pyo3-macros", version = "=0.19.0", optional = true }
indoc = { version = "1.0.3", optional = true }
unindent = { version = "0.1.4", optional = true }
@ -58,7 +58,7 @@ rust_decimal = { version = "1.8.0", features = ["std"] }
widestring = "0.5.1"
[build-dependencies]
pyo3-build-config = { path = "pyo3-build-config", version = "0.18.3", features = ["resolve-config"] }
pyo3-build-config = { path = "pyo3-build-config", version = "0.19.0", features = ["resolve-config"] }
[features]
default = ["macros"]

View File

@ -68,7 +68,7 @@ name = "string_sum"
crate-type = ["cdylib"]
[dependencies]
pyo3 = { version = "0.18.3", features = ["extension-module"] }
pyo3 = { version = "0.19.0", 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.18.3"
version = "0.19.0"
features = ["auto-initialize"]
```

View File

@ -5,7 +5,7 @@ publish = false
edition = "2018"
[dev-dependencies]
pyo3 = { version = "0.18.3", path = "..", features = ["auto-initialize", "extension-module"] }
pyo3 = { version = "0.19.0", path = "..", features = ["auto-initialize", "extension-module"] }
[[example]]
name = "decorator"

View File

@ -1,4 +1,4 @@
variable::set("PYO3_VERSION", "0.18.3");
variable::set("PYO3_VERSION", "0.19.0");
file::rename(".template/Cargo.toml", "Cargo.toml");
file::rename(".template/pyproject.toml", "pyproject.toml");
file::delete(".template");

View File

@ -1,4 +1,4 @@
variable::set("PYO3_VERSION", "0.18.3");
variable::set("PYO3_VERSION", "0.19.0");
file::rename(".template/Cargo.toml", "Cargo.toml");
file::rename(".template/pyproject.toml", "pyproject.toml");
file::delete(".template");

View File

@ -1,4 +1,4 @@
variable::set("PYO3_VERSION", "0.18.3");
variable::set("PYO3_VERSION", "0.19.0");
file::rename(".template/Cargo.toml", "Cargo.toml");
file::rename(".template/plugin_api/Cargo.toml", "plugin_api/Cargo.toml");
file::delete(".template");

View File

@ -1,4 +1,4 @@
variable::set("PYO3_VERSION", "0.18.3");
variable::set("PYO3_VERSION", "0.19.0");
file::rename(".template/Cargo.toml", "Cargo.toml");
file::rename(".template/setup.cfg", "setup.cfg");
file::delete(".template");

View File

@ -1,3 +1,3 @@
variable::set("PYO3_VERSION", "0.18.3");
variable::set("PYO3_VERSION", "0.19.0");
file::rename(".template/Cargo.toml", "Cargo.toml");
file::delete(".template");

View File

@ -5,6 +5,27 @@ For a detailed list of all changes, see the [CHANGELOG](changelog.md).
## from 0.18.* to 0.19
### Access to `Python` inside `__traverse__` implementations are now forbidden
During `__traverse__` implementations for Python's Garbage Collection it is forbidden to do anything other than visit the members of the `#[pyclass]` being traversed. This means making Python function calls or other API calls are forbidden.
Previous versions of PyO3 would allow access to `Python` (e.g. via `Python::with_gil`), which could cause the Python interpreter to crash or otherwise confuse the garbage collection algorithm.
Attempts to acquire the GIL will now panic. See [#3165](https://github.com/PyO3/pyo3/issues/3165) for more detail.
```rust,ignore
# use pyo3::prelude::*;
#[pyclass]
struct SomeClass {}
impl SomeClass {
fn __traverse__(&self, pyo3::class::gc::PyVisit<'_>) -> Result<(), pyo3::class::gc::PyTraverseError>` {
Python::with_gil(|| { /*...*/ }) // ERROR: this will panic
}
}
```
### Smarter `anyhow::Error` / `eyre::Report` conversion when inner error is "simple" `PyErr`
When converting from `anyhow::Error` or `eyre::Report` to `PyErr`, if the inner error is a "simple" `PyErr` (with no source error), then the inner error will be used directly as the `PyErr` instead of wrapping it in a new `PyRuntimeError` with the original information converted into a string.

View File

@ -1 +0,0 @@
`PyAny::is_instance_of::<T>(obj)` is now equivalent to `T::is_type_of(obj)`, and now returns `bool` instead of `PyResult<bool>`.

View File

@ -1 +0,0 @@
Support `text_signature` option (and automatically generate signature) for `#[new]` in `#[pymethods]`.

View File

@ -1 +0,0 @@
Deprecate `text_signature` option on `#[pyclass]`.

View File

@ -1 +0,0 @@
Remove all functionality deprecated in PyO3 0.17, most prominently `Python::acquire_gil` is replaced by `Python::with_gil`.

View File

@ -1 +0,0 @@
`anyhow::Error`/`eyre::Report` containing a basic `PyErr` won't be wrapped in a `PyRuntimeError` on conversion, if it's not chained.

View File

@ -1 +0,0 @@
Added support for converting to and from Python's `decimal.Decimal` and `rust_decimal::Decimal`.

View File

@ -1 +0,0 @@
- Change `#[getter]` and `#[setter]` to use a common call "trampoline" to slightly reduce generated code size and compile times.

View File

@ -1 +0,0 @@
Correct FFI definitions `PyGetSetDef`, `PyMemberDef`, `PyStructSequence_Field` and `PyStructSequence_Desc` to have `*const c_char` members for `name` and `doc` (not `*mut c_char`).

View File

@ -1 +0,0 @@
Improve default values for str, numbers and bool in automatically-generated `text_signature`.

View File

@ -1 +0,0 @@
Stop panic on `fmt::Display`, instead return `"<unprintable object>"` string and report error via `sys.unraisablehook()`

View File

@ -1 +0,0 @@
Improve default value for `None` in `text_signature`.

View File

@ -1 +0,0 @@
Rename `PySequence::list` and `PySequence::tuple` to `PySequence::to_list` and `PySequence::to_tuple`. (The old names continue to exist as deprecated forms.)

View File

@ -1 +0,0 @@
Allow using `#[pyo3(from_item_all)]` when deriving `FromPyObject` to specify `get_item` as getter for all fields.

View File

@ -1 +0,0 @@
Extend the lifetime of the GIL token returned by `PyRef::py` and `PyRefMut::py` to match the underlying borrow.

View File

@ -1 +0,0 @@
Add FFI definition for `BaseExceptionGroup`, which was added in Python 3.11 by [PEP 0654](https://peps.python.org/pep-0654/).

View File

@ -1 +0,0 @@
Extend lifetime of holder variables to avoid "temporary value dropped while borrowed" errors when `#[pyfunction]`s take references into `#[pyclass]`es

View File

@ -1 +0,0 @@
Added a few lines to document the main difference between maturin and setuptools-rust as far as building manylinux-compliant wheels is concerned.

View File

@ -1 +0,0 @@
Correct dependency on syn to version 1.0.85 instead of the incorrect version 1.0.56.

View File

@ -1 +0,0 @@
Allow combining `#[new]` and `#[classmethod]` to create a constructor which receives a (subtype's) class/`PyType` as its first argument.

View File

@ -1 +0,0 @@
Add `PyClass::get` and `Py::get` for GIL-indepedent access to internally synchronized frozen classes.

View File

@ -1 +0,0 @@
Add `PyAny::is_exact_instance` and `PyAny::is_exact_instance_of`.

View File

@ -1 +0,0 @@
Safe access to the GIL, for example via `Python::with_gil`, is now locked inside of implementations of the `__traverse__` slot.

View File

@ -1 +0,0 @@
Do not apply deferred reference count updates when entering a `__traverse__` implementation is it cannot alter any reference counts while the garbage collector is running.

View File

@ -1 +0,0 @@
Avoid running the `Drop` implementations of unsendable classes on other threads

View File

@ -1 +0,0 @@
Fix a compile error when `#[pymethods]` items come from somewhere else (for example, as a macro argument) and a custom receiver like `Py<Self>` is used.

View File

@ -1,6 +1,6 @@
[package]
name = "pyo3-build-config"
version = "0.18.3"
version = "0.19.0"
description = "Build configuration for the PyO3 ecosystem"
authors = ["PyO3 Project and Contributors <https://github.com/PyO3>"]
keywords = ["pyo3", "python", "cpython", "ffi"]

View File

@ -1,6 +1,6 @@
[package]
name = "pyo3-ffi"
version = "0.18.3"
version = "0.19.0"
description = "Python-API bindings for the PyO3 ecosystem"
authors = ["PyO3 Project and Contributors <https://github.com/PyO3>"]
keywords = ["pyo3", "python", "cpython", "ffi"]
@ -38,4 +38,4 @@ generate-import-lib = ["pyo3-build-config/python3-dll-a"]
[build-dependencies]
pyo3-build-config = { path = "../pyo3-build-config", version = "0.18.3", features = ["resolve-config"] }
pyo3-build-config = { path = "../pyo3-build-config", version = "0.19.0", features = ["resolve-config"] }

View File

@ -1,6 +1,6 @@
[package]
name = "pyo3-macros-backend"
version = "0.18.3"
version = "0.19.0"
description = "Code generation for PyO3 package"
authors = ["PyO3 Project and Contributors <https://github.com/PyO3>"]
keywords = ["pyo3", "python", "cpython", "ffi"]

View File

@ -1,6 +1,6 @@
[package]
name = "pyo3-macros"
version = "0.18.3"
version = "0.19.0"
description = "Proc macros for PyO3 package"
authors = ["PyO3 Project and Contributors <https://github.com/PyO3>"]
keywords = ["pyo3", "python", "cpython", "ffi"]
@ -22,4 +22,4 @@ abi3 = ["pyo3-macros-backend/abi3"]
proc-macro2 = { version = "1", default-features = false }
quote = "1"
syn = { version = "1.0.85", features = ["full", "extra-traits"] }
pyo3-macros-backend = { path = "../pyo3-macros-backend", version = "=0.18.3" }
pyo3-macros-backend = { path = "../pyo3-macros-backend", version = "=0.19.0" }

View File

@ -20,7 +20,7 @@ exclude = '''
[tool.towncrier]
filename = "CHANGELOG.md"
version = "0.18.3"
version = "0.19.0"
start_string = "<!-- towncrier release notes start -->\n"
template = ".towncrier.template.md"
title_format = "## [{version}] - {project_date}"