Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: 0.19.0 #3187

Merged
merged 1 commit into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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 }

Expand Down Expand Up @@ -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"]
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`**
Expand Down Expand Up @@ -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"]
```

Expand Down
2 changes: 1 addition & 1 deletion examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion examples/decorator/.template/pre-script.rhai
Original file line number Diff line number Diff line change
@@ -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");
2 changes: 1 addition & 1 deletion examples/maturin-starter/.template/pre-script.rhai
Original file line number Diff line number Diff line change
@@ -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");
2 changes: 1 addition & 1 deletion examples/plugin/.template/pre-script.rhai
Original file line number Diff line number Diff line change
@@ -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");
2 changes: 1 addition & 1 deletion examples/setuptools-rust-starter/.template/pre-script.rhai
Original file line number Diff line number Diff line change
@@ -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");
2 changes: 1 addition & 1 deletion examples/word-count/.template/pre-script.rhai
Original file line number Diff line number Diff line change
@@ -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");
21 changes: 21 additions & 0 deletions guide/src/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion newsfragments/2881.changed.md

This file was deleted.

1 change: 0 additions & 1 deletion newsfragments/2980.added.md

This file was deleted.

1 change: 0 additions & 1 deletion newsfragments/2980.changed.md

This file was deleted.

1 change: 0 additions & 1 deletion newsfragments/2981.removed.md

This file was deleted.

1 change: 0 additions & 1 deletion newsfragments/3004.changed.md

This file was deleted.

1 change: 0 additions & 1 deletion newsfragments/3016.added.md

This file was deleted.

1 change: 0 additions & 1 deletion newsfragments/3029.changed.md

This file was deleted.

1 change: 0 additions & 1 deletion newsfragments/3036.fixed.md

This file was deleted.

1 change: 0 additions & 1 deletion newsfragments/3050.changed.md

This file was deleted.

1 change: 0 additions & 1 deletion newsfragments/3062.fixed.md

This file was deleted.

1 change: 0 additions & 1 deletion newsfragments/3066.changed.md

This file was deleted.

1 change: 0 additions & 1 deletion newsfragments/3111.changed.md

This file was deleted.

1 change: 0 additions & 1 deletion newsfragments/3120.added.md

This file was deleted.

1 change: 0 additions & 1 deletion newsfragments/3131.changed.md

This file was deleted.

1 change: 0 additions & 1 deletion newsfragments/3141.added.md

This file was deleted.

1 change: 0 additions & 1 deletion newsfragments/3142.fixed.md

This file was deleted.

1 change: 0 additions & 1 deletion newsfragments/3146.added.md

This file was deleted.

1 change: 0 additions & 1 deletion newsfragments/3152.packaging.md

This file was deleted.

1 change: 0 additions & 1 deletion newsfragments/3157.added.md

This file was deleted.

1 change: 0 additions & 1 deletion newsfragments/3158.added.md

This file was deleted.

1 change: 0 additions & 1 deletion newsfragments/3161.added.md

This file was deleted.

1 change: 0 additions & 1 deletion newsfragments/3168.changed.md

This file was deleted.

1 change: 0 additions & 1 deletion newsfragments/3168.fixed.md

This file was deleted.

1 change: 0 additions & 1 deletion newsfragments/3176.fixed.md

This file was deleted.

1 change: 0 additions & 1 deletion newsfragments/3178.fixed.md

This file was deleted.

2 changes: 1 addition & 1 deletion pyo3-build-config/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down
4 changes: 2 additions & 2 deletions pyo3-ffi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down Expand Up @@ -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"] }
2 changes: 1 addition & 1 deletion pyo3-macros-backend/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down
4 changes: 2 additions & 2 deletions pyo3-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"]
Expand All @@ -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" }
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down