From ca1bbe3d39c3152924a55b23bb87189deb102190 Mon Sep 17 00:00:00 2001 From: David Hewitt <1939362+davidhewitt@users.noreply.github.com> Date: Sun, 15 Jan 2023 13:34:59 +0000 Subject: [PATCH 1/2] add migration notes for PyO3 0.18 --- guide/src/migration.md | 64 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/guide/src/migration.md b/guide/src/migration.md index c5d2bc5de34..cf9a10604aa 100644 --- a/guide/src/migration.md +++ b/guide/src/migration.md @@ -3,6 +3,70 @@ This guide can help you upgrade code through breaking changes from one PyO3 version to the next. For a detailed list of all changes, see the [CHANGELOG](changelog.md). +## from 0.17.* to 0.18 + +### Required arguments after `Option<_>` arguments will no longer be automatically inferred + +In `#[pyfunction]` and `#[pymethods]`, if a "required" function input such as `i32` came after an `Option<_>` input, then the `Option<_>` would be implicitly treated as required. (All trailing `Option<_>` arguments were treated as optional with a default value of `None`). + +Starting with PyO3 0.18, this is deprecated and a future PyO3 version will require a [`#[pyo3(signature = (...))]` option](./function/signature.md) to explicitly declare the programmer's intention. + +Before, x in the below example would be required to be passed from Python code: + +```rust,compile_fail +# #![allow(dead_code)] +# use pyo3::prelude::*; + +#[pyfunction] +fn required_argument_after_option(x: Option, y: i32) { } +``` + +After, specify the intended Python signature explicitly: + +```rust +# #![allow(dead_code)] +# use pyo3::prelude::*; + +// If x really was intended to be required +#[pyfunction(signature = (x, y))] +fn required_argument_after_option_a(x: Option, y: i32) { } + +// If x was intended to be optional, y needs a default too +#[pyfunction(signature = (x=None, y=0))] +fn required_argument_after_option_b(x: Option, y: i32) { } +``` + +### `__text_signature__` is now automatically generated for `#[pyfunction]` and `#[pymethods]` + +The [`#[pyo3(text_signature = "...")]` option](./function/signature.md#making-the-function-signature-available-to-python) was previously the only supported way to set the `__text_signature__` attribute on generated Python functions. + +PyO3 is now able to automatically populate `__text_signature__` for all functions automatically based on their Rust signature (or the [new `#[pyo3(signature = (...))]` option](./function/signature.md)). These automatically-generated `__text_signature__` values will currently only render `...` for all default values. Many `#[pyo3(text_signature = "...")]` options can be removed from functions when updating to PyO3 0.18, however in cases with default values a manual implementation may still be preferred for now. + +As examples: + +```rust +# use pyo3::prelude::*; + +// The `text_signature` option here is no longer necessary, as PyO3 will automatically +// generate exactly the same value. +#[pyfunction(text_signature = "(a, b, c)")] +fn simple_function(a: i32, b: i32, c: i32) {} + +// The `text_signature` still provides value here as of PyO3 0.18, because the automatically +// generated signature would be "(a, b=..., c=...)". +#[pyfunction(signature = (a, b = 1, c = 2), text_signature = "(a, b=1, c=2)")] +fn function_with_defaults(a: i32, b: i32, c: i32) {} + +# fn main() { +# Python::with_gil(|py| { +# let simple = wrap_pyfunction!(simple_function, py).unwrap(); +# assert_eq!(simple.getattr("__text_signature__").unwrap().to_string(), "(a, b, c)"); +# let defaulted = wrap_pyfunction!(function_with_defaults, py).unwrap(); +# assert_eq!(defaulted.getattr("__text_signature__").unwrap().to_string(), "(a, b=1, c=2)"); +# }) +# } +``` + ## from 0.16.* to 0.17 ### Type checks have been changed for `PyMapping` and `PySequence` types From 224a4160b440a8f2577aa8eefa6a98886fc6b86f Mon Sep 17 00:00:00 2001 From: David Hewitt <1939362+davidhewitt@users.noreply.github.com> Date: Sun, 15 Jan 2023 13:11:10 +0000 Subject: [PATCH 2/2] release: 0.18.0 --- CHANGELOG.md | 75 +++++++++++++++++-- Cargo.toml | 8 +- README.md | 4 +- Releasing.md | 4 +- examples/Cargo.toml | 2 +- examples/decorator/.template/pre-script.rhai | 2 +- .../maturin-starter/.template/pre-script.rhai | 2 +- .../.template/pre-script.rhai | 2 +- examples/word-count/.template/pre-script.rhai | 2 +- newsfragments/2398.added.md | 1 - newsfragments/2490.added.md | 1 - newsfragments/2587.removed.md | 1 - newsfragments/2664.changed.md | 1 - newsfragments/2685.changed.md | 1 - newsfragments/2686.changed.md | 1 - newsfragments/2692.added.md | 1 - newsfragments/2695.changed.md | 3 - newsfragments/2702.added.md | 1 - newsfragments/2702.changed.md | 1 - newsfragments/2703.changed.md | 1 - newsfragments/2705.changed.md | 1 - newsfragments/2715.fixed.md | 1 - newsfragments/2726.fixed.md | 1 - newsfragments/2727.added.md | 1 - newsfragments/2730.added.md | 1 - newsfragments/2734.added.md | 2 - newsfragments/2734.changed.md | 3 - newsfragments/2742.added.md | 1 - newsfragments/2749.fixed.md | 2 - newsfragments/2760.fixed.md | 2 - newsfragments/2769.fixed.md | 1 - newsfragments/2772.fixed.md | 1 - newsfragments/2776.added.md | 1 - newsfragments/2784.changed.md | 1 - newsfragments/2788.added.md | 1 - newsfragments/2795.changed.md | 1 - newsfragments/2796.changed.md | 1 - newsfragments/2800.fixed.md | 1 - newsfragments/2811.added.md | 1 - newsfragments/2811.fixed.md | 1 - newsfragments/2827.added.md | 1 - newsfragments/2838.changed.md | 1 - newsfragments/2842.fixed.md | 1 - newsfragments/2843.removed.md | 1 - newsfragments/2849.packaging.md | 1 - newsfragments/2875.changed.md | 1 - newsfragments/2879.changed.md | 1 - pyo3-build-config/Cargo.toml | 2 +- pyo3-ffi/Cargo.toml | 4 +- pyo3-macros-backend/Cargo.toml | 2 +- pyo3-macros/Cargo.toml | 4 +- pyproject.toml | 2 +- 52 files changed, 87 insertions(+), 73 deletions(-) delete mode 100644 newsfragments/2398.added.md delete mode 100644 newsfragments/2490.added.md delete mode 100644 newsfragments/2587.removed.md delete mode 100644 newsfragments/2664.changed.md delete mode 100644 newsfragments/2685.changed.md delete mode 100644 newsfragments/2686.changed.md delete mode 100644 newsfragments/2692.added.md delete mode 100644 newsfragments/2695.changed.md delete mode 100644 newsfragments/2702.added.md delete mode 100644 newsfragments/2702.changed.md delete mode 100644 newsfragments/2703.changed.md delete mode 100644 newsfragments/2705.changed.md delete mode 100644 newsfragments/2715.fixed.md delete mode 100644 newsfragments/2726.fixed.md delete mode 100644 newsfragments/2727.added.md delete mode 100644 newsfragments/2730.added.md delete mode 100644 newsfragments/2734.added.md delete mode 100644 newsfragments/2734.changed.md delete mode 100644 newsfragments/2742.added.md delete mode 100644 newsfragments/2749.fixed.md delete mode 100644 newsfragments/2760.fixed.md delete mode 100644 newsfragments/2769.fixed.md delete mode 100644 newsfragments/2772.fixed.md delete mode 100644 newsfragments/2776.added.md delete mode 100644 newsfragments/2784.changed.md delete mode 100644 newsfragments/2788.added.md delete mode 100644 newsfragments/2795.changed.md delete mode 100644 newsfragments/2796.changed.md delete mode 100644 newsfragments/2800.fixed.md delete mode 100644 newsfragments/2811.added.md delete mode 100644 newsfragments/2811.fixed.md delete mode 100644 newsfragments/2827.added.md delete mode 100644 newsfragments/2838.changed.md delete mode 100644 newsfragments/2842.fixed.md delete mode 100644 newsfragments/2843.removed.md delete mode 100644 newsfragments/2849.packaging.md delete mode 100644 newsfragments/2875.changed.md delete mode 100644 newsfragments/2879.changed.md diff --git a/CHANGELOG.md b/CHANGELOG.md index afac9f72c65..ce9fdd205e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,64 @@ To see unreleased changes, please see the [CHANGELOG on the main branch guide](h +## [0.18.0] - 2023-01-17 + +### Packaging + +- Relax `indexmap` optional depecency to allow `>= 1.6, < 2`. [#2849](https://github.com/PyO3/pyo3/pull/2849 +- Relax `hashbrown` optional dependency to allow `>= 0.9, < 0.14`. [#2875](https://github.com/PyO3/pyo3/pull/2875) +- Update `memoffset` dependency to 0.8. [#2875](https://github.com/PyO3/pyo3/pull/2875) + +### Added + +- Add `GILOnceCell::get_or_try_init` for fallible `GILOnceCell` initialization. [#2398](https://github.com/PyO3/pyo3/pull/2398) +- Add experimental feature `experimental-inspect` with `type_input()` and `type_output()` helpers to get the Python type of any Python-compatible object. [#2490](https://github.com/PyO3/pyo3/pull/2490) [#2882](https://github.com/PyO3/pyo3/pull/2882) +- The `#[pyclass]` macro can now take `get_all` and `set_all` to create getters and setters for every field. [#2692](https://github.com/PyO3/pyo3/pull/2692) +- Add `#[pyo3(signature = (...))]` option for `#[pyfunction]` and `#[pymethods]`. [#2702](https://github.com/PyO3/pyo3/pull/2702) +- `pyo3-build-config`: rebuild when `PYO3_ENVIRONMENT_SIGNATURE` environment variable value changes. [#2727](https://github.com/PyO3/pyo3/pull/2727) +- Add conversions between non-zero int types in `std::num` and Python `int`. [#2730](https://github.com/PyO3/pyo3/pull/2730) +- Add `Py::downcast()` as a companion to `PyAny::downcast()`, as well as `downcast_unchecked()` for both types. [#2734](https://github.com/PyO3/pyo3/pull/2734) +- Add types for all built-in `Warning` classes as well as `PyErr::warn_explicit`. [#2742](https://github.com/PyO3/pyo3/pull/2742) +- Add `abi3-py311` feature. [#2776](https://github.com/PyO3/pyo3/pull/2776) +- Add FFI definition `_PyErr_ChainExceptions()` for CPython. [#2788](https://github.com/PyO3/pyo3/pull/2788) +- Add FFI definitions `PyVectorcall_NARGS` and `PY_VECTORCALL_ARGUMENTS_OFFSET` for PyPy 3.8 and up. [#2811](https://github.com/PyO3/pyo3/pull/2811) +- Add `PyList::get_item_unchecked` for PyPy. [#2827](https://github.com/PyO3/pyo3/pull/2827) + +### Changed + +- PyO3's macros now emit a much nicer error message if function return values don't implement the required trait(s). [#2664](https://github.com/PyO3/pyo3/pull/2664) +- Use a TypeError, rather than a ValueError, when refusing to treat a str as a Vec. [#2685](https://github.com/PyO3/pyo3/pull/2685) +- Change `PyCFunction::new_closure` to take `name` and `doc` arguments. [#2686](https://github.com/PyO3/pyo3/pull/2686) +- `PyType::is_subclass`, `PyErr::is_instance` and `PyAny::is_instance` now take `&PyAny` instead of `&PyType` arguments, so that they work with objects that pretend to be types using `__subclasscheck__` and `__instancecheck__`. [#2695](https://github.com/PyO3/pyo3/pull/2695) +- Deprecate `#[args]` attribute and passing "args" specification directly to `#[pyfunction]` in favor of the new `#[pyo3(signature = (...))]` option. [#2702](https://github.com/PyO3/pyo3/pull/2702) +- Deprecate required arguments after `Option` arguments to `#[pyfunction]` and `#[pymethods]` without also using `#[pyo3(signature)]` to specify whether the arguments should be required or have defaults. [#2703](https://github.com/PyO3/pyo3/pull/2703) +- Change `#[pyfunction]` and `#[pymethods]` to use a common call "trampoline" to slightly reduce generated code size and compile times. [#2705](https://github.com/PyO3/pyo3/pull/2705) +- `PyAny::cast_as()` and `Py::cast_as()` are now deprecated in favor of `PyAny::downcast()` and the new `Py::downcast()`. [#2734](https://github.com/PyO3/pyo3/pull/2734) +- Relax lifetime bounds on `PyAny::downcast()`. [#2734](https://github.com/PyO3/pyo3/pull/2734) +- Automatically generate `__text_signature__` for all Python functions created using `#[pyfunction]` and `#[pymethods]`. [#2784](https://github.com/PyO3/pyo3/pull/2784) +- Accept any iterator in `PySet::new` and `PyFrozenSet::new`. [#2795](https://github.com/PyO3/pyo3/pull/2795) +- Mixing `#[cfg(...)]` and `#[pyo3(...)]` attributes on `#[pyclass]` struct fields will now work. [#2796](https://github.com/PyO3/pyo3/pull/2796) +- Re-enable `PyFunction` on when building for abi3 or PyPy. [#2838](https://github.com/PyO3/pyo3/pull/2838) +- Improve `derive(FromPyObject)` to use `intern!` when applicable for `#[pyo3(item)]`. [#2838](https://github.com/PyO3/pyo3/pull/2838) + +### Removed + +- Remove the deprecated `pyproto` feature, `#[pyproto]` macro, and all accompanying APIs. [#2587](https://github.com/PyO3/pyo3/pull/2587) +- Remove all functionality deprecated in PyO3 0.16. [#2843](https://github.com/PyO3/pyo3/pull/2843) + +### Fixed + +- Disable `PyModule::filename` on PyPy. [#2715](https://github.com/PyO3/pyo3/pull/2715) +- `PyCodeObject` is now once again defined with fields on Python 3.7. [#2726](https://github.com/PyO3/pyo3/pull/2726) +- Raise a `TypeError` if `#[new]` pymethods with no arguments receive arguments when called from Python. [#2749](https://github.com/PyO3/pyo3/pull/2749) +- Use the `NOARGS` argument calling convention for methods that have a single `py: Python` argument (as a performance optimization). [#2760](https://github.com/PyO3/pyo3/pull/2760) +- Fix truncation of `isize` values to `c_long` in `PySlice::new`. [#2769](https://github.com/PyO3/pyo3/pull/2769) +- Fix soundness issue with FFI definition `PyUnicodeDecodeError_Create` on PyPy leading to indeterminate behavior (typically a `TypeError`). [#2772](https://github.com/PyO3/pyo3/pull/2772) +- Allow functions taking `**kwargs` to accept keyword arguments which share a name with a positional-only argument (as permitted by PEP 570). [#2800](https://github.com/PyO3/pyo3/pull/2800) +- Fix unresolved symbol for `PyObject_Vectorcall` on PyPy 3.9 and up. [#2811](https://github.com/PyO3/pyo3/pull/2811) +- Fix memory leak in `PyCFunction::new_closure`. [#2842](https://github.com/PyO3/pyo3/pull/2842) + + ## [0.17.3] - 2022-11-01 ### Packaging @@ -93,7 +151,7 @@ To see unreleased changes, please see the [CHANGELOG on the main branch guide](h - Rework `PyCapsule` type to resolve soundness issues: [#2485](https://github.com/PyO3/pyo3/pull/2485) - `PyCapsule::new` and `PyCapsule::new_with_destructor` now take `name: Option` 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::get_context` deprecated in favor 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>` instead of `&CStr`. - `FromPyObject::extract` for `Vec` no longer accepts Python `str` inputs. [#2500](https://github.com/PyO3/pyo3/pull/2500) @@ -138,7 +196,7 @@ To see unreleased changes, please see the [CHANGELOG on the main branch guide](h ## [0.16.6] - 2022-08-23 -### Changed +### Changed - Fix soundness issues with `PyCapsule` type with select workarounds. Users are encourage to upgrade to PyO3 0.17 at their earliest convenience which contains API breakages which fix the issues in a long-term fashion. [#2522](https://github.com/PyO3/pyo3/pull/2522) - `PyCapsule::new` and `PyCapsule::new_with_destructor` now take ownership of a copy of the `name` to resolve a possible use-after-free. @@ -204,7 +262,7 @@ To see unreleased changes, please see the [CHANGELOG on the main branch guide](h - Allow `#[pyo3(crate = "...", text_signature = "...")]` options to be used directly in `#[pyclass(crate = "...", text_signature = "...")]`. [#2234](https://github.com/PyO3/pyo3/pull/2234) - Make `PYO3_CROSS_LIB_DIR` environment variable optional when cross compiling. [#2241](https://github.com/PyO3/pyo3/pull/2241) - Mark `METH_FASTCALL` calling convention as limited API on Python 3.10. [#2250](https://github.com/PyO3/pyo3/pull/2250) -- Deprecate `pyo3_build_config::cross_compiling` in favour of `pyo3_build_config::cross_compiling_from_to`. [#2253](https://github.com/PyO3/pyo3/pull/2253) +- Deprecate `pyo3_build_config::cross_compiling` in favor of `pyo3_build_config::cross_compiling_from_to`. [#2253](https://github.com/PyO3/pyo3/pull/2253) ### Fixed @@ -284,7 +342,7 @@ To see unreleased changes, please see the [CHANGELOG on the main branch guide](h - Add modulo argument to `__ipow__` magic method. [#2083](https://github.com/PyO3/pyo3/pull/2083) - Fix FFI definition for `_PyCFunctionFast`. [#2126](https://github.com/PyO3/pyo3/pull/2126) - `PyDateTimeAPI` and `PyDateTime_TimeZone_UTC` are are now unsafe functions instead of statics. [#2126](https://github.com/PyO3/pyo3/pull/2126) -- `PyDateTimeAPI` does not implicitly call `PyDateTime_IMPORT` anymore to reflect the original Python API more closely. Before the first call to `PyDateTime_IMPORT` a null pointer is returned. Therefore before calling any of the following FFI functions `PyDateTime_IMPORT` must be called to avoid undefined behaviour: [#2126](https://github.com/PyO3/pyo3/pull/2126) +- `PyDateTimeAPI` does not implicitly call `PyDateTime_IMPORT` anymore to reflect the original Python API more closely. Before the first call to `PyDateTime_IMPORT` a null pointer is returned. Therefore before calling any of the following FFI functions `PyDateTime_IMPORT` must be called to avoid undefined behavior: [#2126](https://github.com/PyO3/pyo3/pull/2126) - `PyDateTime_TimeZone_UTC` - `PyDate_Check` - `PyDate_CheckExact` @@ -317,7 +375,7 @@ To see unreleased changes, please see the [CHANGELOG on the main branch guide](h - Fix the `wrap_pymodule!` macro using the wrong name for a `#[pymodule]` with a `#[pyo3(name = "..")]` attribute. [#2081](https://github.com/PyO3/pyo3/pull/2081) - Fix magic methods in `#[pymethods]` accepting implementations with the wrong number of arguments. [#2083](https://github.com/PyO3/pyo3/pull/2083) - Fix panic in `#[pyfunction]` generated code when a required argument following an `Option` was not provided. [#2093](https://github.com/PyO3/pyo3/pull/2093) -- Fixed undefined behaviour caused by incorrect `ExactSizeIterator` implementations. [#2124](https://github.com/PyO3/pyo3/pull/2124) +- Fixed undefined behavior caused by incorrect `ExactSizeIterator` implementations. [#2124](https://github.com/PyO3/pyo3/pull/2124) - Fix missing FFI definition `PyCMethod_New` on Python 3.9 and up. [#2143](https://github.com/PyO3/pyo3/pull/2143) - Add missing FFI definitions `_PyLong_NumBits` and `_PyLong_AsByteArray` on PyPy. [#2146](https://github.com/PyO3/pyo3/pull/2146) - Fix memory leak in implementation of `AsPyPointer` for `Option`. [#2160](https://github.com/PyO3/pyo3/pull/2160) @@ -639,7 +697,7 @@ To see unreleased changes, please see the [CHANGELOG on the main branch guide](h ### Added -- Add support for building for CPython limited API. Opting-in to the limited API enables a single extension wheel built with PyO3 to be installable on multiple Python versions. This required a few minor changes to runtime behaviour of of PyO3 `#[pyclass]` types. See the migration guide for full details. [#1152](https://github.com/PyO3/pyo3/pull/1152) +- Add support for building for CPython limited API. Opting-in to the limited API enables a single extension wheel built with PyO3 to be installable on multiple Python versions. This required a few minor changes to runtime behavior of of PyO3 `#[pyclass]` types. See the migration guide for full details. [#1152](https://github.com/PyO3/pyo3/pull/1152) - Add feature flags `abi3-py36`, `abi3-py37`, `abi3-py38` etc. to set the minimum Python version when using the limited API. [#1263](https://github.com/PyO3/pyo3/pull/1263) - Add argument names to `TypeError` messages generated by pymethod wrappers. [#1212](https://github.com/PyO3/pyo3/pull/1212) - Add FFI definitions for PEP 587 "Python Initialization Configuration". [#1247](https://github.com/PyO3/pyo3/pull/1247) @@ -941,7 +999,7 @@ To see unreleased changes, please see the [CHANGELOG on the main branch guide](h - Usage of raw identifiers with `#[pyo3(set)]`. [#745](https://github.com/PyO3/pyo3/pull/745) - Usage of `PyObject` with `#[pyo3(get)]`. [#760](https://github.com/PyO3/pyo3/pull/760) - `#[pymethods]` used in conjunction with `#[cfg]`. #[769](https://github.com/PyO3/pyo3/pull/769) -- `"*"` in a `#[pyfunction()]` argument list incorrectly accepting any number of positional arguments (use `args = "*"` when this behaviour is desired). #[792](https://github.com/PyO3/pyo3/pull/792) +- `"*"` in a `#[pyfunction()]` argument list incorrectly accepting any number of positional arguments (use `args = "*"` when this behavior is desired). #[792](https://github.com/PyO3/pyo3/pull/792) - `PyModule::dict`. #[809](https://github.com/PyO3/pyo3/pull/809) - Fix the case where `DESCRIPTION` is not null-terminated. #[822](https://github.com/PyO3/pyo3/pull/822) @@ -1311,7 +1369,8 @@ Yanked - Initial release -[Unreleased]: https://github.com/pyo3/pyo3/compare/v0.17.3...HEAD +[Unreleased]: https://github.com/pyo3/pyo3/compare/v0.18.0...HEAD +[0.18.0]: https://github.com/pyo3/pyo3/compare/v0.17.3...v0.18.0 [0.17.3]: https://github.com/pyo3/pyo3/compare/v0.17.2...v0.17.3 [0.17.2]: https://github.com/pyo3/pyo3/compare/v0.17.1...v0.17.2 [0.17.1]: https://github.com/pyo3/pyo3/compare/v0.17.0...v0.17.1 diff --git a/Cargo.toml b/Cargo.toml index 58f30e78200..b6946f6fe8c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pyo3" -version = "0.17.3" +version = "0.18.0" description = "Bindings to Python interpreter" authors = ["PyO3 Project and Contributors "] readme = "README.md" @@ -20,10 +20,10 @@ parking_lot = ">= 0.11, < 0.13" memoffset = "0.8" # ffi bindings to the python interpreter, split into a separate crate so they can be used independently -pyo3-ffi = { path = "pyo3-ffi", version = "=0.17.3" } +pyo3-ffi = { path = "pyo3-ffi", version = "=0.18.0" } # support crates for macros feature -pyo3-macros = { path = "pyo3-macros", version = "=0.17.3", optional = true } +pyo3-macros = { path = "pyo3-macros", version = "=0.18.0", optional = true } indoc = { version = "1.0.3", optional = true } unindent = { version = "0.1.4", optional = true } @@ -56,7 +56,7 @@ rayon = "1.0.2" widestring = "0.5.1" [build-dependencies] -pyo3-build-config = { path = "pyo3-build-config", version = "0.17.3", features = ["resolve-config"] } +pyo3-build-config = { path = "pyo3-build-config", version = "0.18.0", features = ["resolve-config"] } [features] default = ["macros"] diff --git a/README.md b/README.md index 004fe592c43..63c125e1426 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ name = "string_sum" crate-type = ["cdylib"] [dependencies] -pyo3 = { version = "0.17.3", features = ["extension-module"] } +pyo3 = { version = "0.18.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.17.3" +version = "0.18.0" features = ["auto-initialize"] ``` diff --git a/Releasing.md b/Releasing.md index 29abdd5feaa..3692c1f0a0b 100644 --- a/Releasing.md +++ b/Releasing.md @@ -35,7 +35,7 @@ Write release notes which match the style of previous releases. You can get the Save as a draft and wait for now. -## 3. Leave for a cooling off period +## 3. Leave for a cooling off period Wait a couple of days in case anyone wants to hold up the release to add bugfixes etc. @@ -50,6 +50,6 @@ To put live: If the release PR targeted a branch other than main, you will need to cherry-pick the version bumps, CHANGELOG modifications and removal of towncrier `newsfragments` and open another PR to land these on main. -## 6. Delete the release branch (patch releases only) +## 6. Delete the release branch (patch releases only) For 0.X.Y patch releases, the release branch is no longer needed, so it should be deleted. diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 1b97a1c8844..52a8069ff2d 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -5,7 +5,7 @@ publish = false edition = "2018" [dev-dependencies] -pyo3 = { version = "0.17.3", path = "..", features = ["auto-initialize", "extension-module"] } +pyo3 = { version = "0.18.0", path = "..", features = ["auto-initialize", "extension-module"] } [[example]] name = "decorator" diff --git a/examples/decorator/.template/pre-script.rhai b/examples/decorator/.template/pre-script.rhai index 75638cc87d5..c9759acc70e 100644 --- a/examples/decorator/.template/pre-script.rhai +++ b/examples/decorator/.template/pre-script.rhai @@ -1,4 +1,4 @@ -variable::set("PYO3_VERSION", "0.17.3"); +variable::set("PYO3_VERSION", "0.18.0"); file::rename(".template/Cargo.toml", "Cargo.toml"); file::rename(".template/pyproject.toml", "pyproject.toml"); file::rename(".template/tox.ini", "tox.ini"); diff --git a/examples/maturin-starter/.template/pre-script.rhai b/examples/maturin-starter/.template/pre-script.rhai index 75638cc87d5..c9759acc70e 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.17.3"); +variable::set("PYO3_VERSION", "0.18.0"); file::rename(".template/Cargo.toml", "Cargo.toml"); file::rename(".template/pyproject.toml", "pyproject.toml"); file::rename(".template/tox.ini", "tox.ini"); diff --git a/examples/setuptools-rust-starter/.template/pre-script.rhai b/examples/setuptools-rust-starter/.template/pre-script.rhai index a12f34aafb5..69574a02fdb 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.17.3"); +variable::set("PYO3_VERSION", "0.18.0"); file::rename(".template/Cargo.toml", "Cargo.toml"); file::rename(".template/setup.cfg", "setup.cfg"); file::rename(".template/tox.ini", "tox.ini"); diff --git a/examples/word-count/.template/pre-script.rhai b/examples/word-count/.template/pre-script.rhai index ddac6b62f8d..88f41205d08 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.17.3"); +variable::set("PYO3_VERSION", "0.18.0"); file::rename(".template/Cargo.toml", "Cargo.toml"); file::rename(".template/tox.ini", "tox.ini"); file::delete(".template"); diff --git a/newsfragments/2398.added.md b/newsfragments/2398.added.md deleted file mode 100644 index a547d451c8d..00000000000 --- a/newsfragments/2398.added.md +++ /dev/null @@ -1 +0,0 @@ -Add `GILOnceCell::get_or_try_init` for fallible `GILOnceCell` initialization. diff --git a/newsfragments/2490.added.md b/newsfragments/2490.added.md deleted file mode 100644 index f1d85bc3240..00000000000 --- a/newsfragments/2490.added.md +++ /dev/null @@ -1 +0,0 @@ -Added `type_input()` and `type_output()` to get the Python type of any Python-compatible object. diff --git a/newsfragments/2587.removed.md b/newsfragments/2587.removed.md deleted file mode 100644 index 65650998cee..00000000000 --- a/newsfragments/2587.removed.md +++ /dev/null @@ -1 +0,0 @@ -Remove the deprecated `pyproto` feature, `#[pyproto]` macro, and all accompanying APIs. diff --git a/newsfragments/2664.changed.md b/newsfragments/2664.changed.md deleted file mode 100644 index 7dd461d7fb5..00000000000 --- a/newsfragments/2664.changed.md +++ /dev/null @@ -1 +0,0 @@ -PyO3's macros now emit a much nicer error message if function return values don't implement the required trait(s). \ No newline at end of file diff --git a/newsfragments/2685.changed.md b/newsfragments/2685.changed.md deleted file mode 100644 index 8e498fe167b..00000000000 --- a/newsfragments/2685.changed.md +++ /dev/null @@ -1 +0,0 @@ -Use a TypeError, rather than a ValueError, when refusing to treat a str as a Vec diff --git a/newsfragments/2686.changed.md b/newsfragments/2686.changed.md deleted file mode 100644 index a1c54ea07a0..00000000000 --- a/newsfragments/2686.changed.md +++ /dev/null @@ -1 +0,0 @@ -Change PyCFunction::new_closure to take name and doc arguments. diff --git a/newsfragments/2692.added.md b/newsfragments/2692.added.md deleted file mode 100644 index d6e45677907..00000000000 --- a/newsfragments/2692.added.md +++ /dev/null @@ -1 +0,0 @@ -The `#[pyclass]` macro can now take `get_all` and `set_all` to create getters and setters for every field. \ No newline at end of file diff --git a/newsfragments/2695.changed.md b/newsfragments/2695.changed.md deleted file mode 100644 index 4765f35a939..00000000000 --- a/newsfragments/2695.changed.md +++ /dev/null @@ -1,3 +0,0 @@ -`PyType::is_subclass`, `PyErr::is_instance` and `PyAny::is_instance` now take -`&PyAny` instead of `&PyType` arguments, so that they work with objects that -pretend to be types using `__subclasscheck__` and `__instancecheck__`. diff --git a/newsfragments/2702.added.md b/newsfragments/2702.added.md deleted file mode 100644 index 6fa67fe130c..00000000000 --- a/newsfragments/2702.added.md +++ /dev/null @@ -1 +0,0 @@ -Add `#[pyo3(signature = (...))]` option for `#[pyfunction]` and `#[pymethods]`. diff --git a/newsfragments/2702.changed.md b/newsfragments/2702.changed.md deleted file mode 100644 index e39fd3a8058..00000000000 --- a/newsfragments/2702.changed.md +++ /dev/null @@ -1 +0,0 @@ -Deprecate `#[args]` attribute and passing "args" specification directly to `#[pyfunction]` in favour of the new `#[pyo3(signature = (...))]` option. diff --git a/newsfragments/2703.changed.md b/newsfragments/2703.changed.md deleted file mode 100644 index bc67791e120..00000000000 --- a/newsfragments/2703.changed.md +++ /dev/null @@ -1 +0,0 @@ -Deprecate required arguments after `Option` arguments to `#[pyfunction]` and `#[pymethods]` without also using `#[pyo3(signature)]` to specify whether the arguments should be required or have defaults. diff --git a/newsfragments/2705.changed.md b/newsfragments/2705.changed.md deleted file mode 100644 index 8365fc01118..00000000000 --- a/newsfragments/2705.changed.md +++ /dev/null @@ -1 +0,0 @@ -Change `#[pyfunction]` and `#[pymethods]` to use a common call "trampoline" to slightly reduce generated code size and compile times. diff --git a/newsfragments/2715.fixed.md b/newsfragments/2715.fixed.md deleted file mode 100644 index 00e856ee96a..00000000000 --- a/newsfragments/2715.fixed.md +++ /dev/null @@ -1 +0,0 @@ -Disable `PyModule::filename` on PyPy diff --git a/newsfragments/2726.fixed.md b/newsfragments/2726.fixed.md deleted file mode 100644 index ec8020fe269..00000000000 --- a/newsfragments/2726.fixed.md +++ /dev/null @@ -1 +0,0 @@ -`PyCodeObject` is now once again defined with fields on Python 3.7. diff --git a/newsfragments/2727.added.md b/newsfragments/2727.added.md deleted file mode 100644 index bfc836d8b3f..00000000000 --- a/newsfragments/2727.added.md +++ /dev/null @@ -1 +0,0 @@ -`pyo3-build-config`: rebuild when `PYO3_ENVIRONMENT_SIGNATURE` environment variable value changed diff --git a/newsfragments/2730.added.md b/newsfragments/2730.added.md deleted file mode 100644 index 3507c1cd6a8..00000000000 --- a/newsfragments/2730.added.md +++ /dev/null @@ -1 +0,0 @@ -Add conversions between non-zero int types in `std::num` and Python int. diff --git a/newsfragments/2734.added.md b/newsfragments/2734.added.md deleted file mode 100644 index ccbd31b59fd..00000000000 --- a/newsfragments/2734.added.md +++ /dev/null @@ -1,2 +0,0 @@ -Added `Py::downcast()` as a companion to `PyAny::downcast()`, as well as -`downcast_unchecked()` for both types. diff --git a/newsfragments/2734.changed.md b/newsfragments/2734.changed.md deleted file mode 100644 index 9eb9ff3d1e2..00000000000 --- a/newsfragments/2734.changed.md +++ /dev/null @@ -1,3 +0,0 @@ -`PyAny::cast_as()` and `Py::cast_as()` are now deprecated in favor of -`PyAny::downcast()` and the new `Py::downcast()`. The `PyAny::downcast()` -lifetime bounds where slightly relaxed. diff --git a/newsfragments/2742.added.md b/newsfragments/2742.added.md deleted file mode 100644 index 0d2871ea012..00000000000 --- a/newsfragments/2742.added.md +++ /dev/null @@ -1 +0,0 @@ -Added exports for all built-in `Warning` classes as well as `PyErr::warn_explicit`. diff --git a/newsfragments/2749.fixed.md b/newsfragments/2749.fixed.md deleted file mode 100644 index e37742a1715..00000000000 --- a/newsfragments/2749.fixed.md +++ /dev/null @@ -1,2 +0,0 @@ -Fix a bug that allowed `#[new]` pymethods with no arguments to be called from -Python with any argument list. diff --git a/newsfragments/2760.fixed.md b/newsfragments/2760.fixed.md deleted file mode 100644 index 65f543e6b61..00000000000 --- a/newsfragments/2760.fixed.md +++ /dev/null @@ -1,2 +0,0 @@ -Also apply the `NOARGS` argument convention to methods that have a single -`py: Python` argument. diff --git a/newsfragments/2769.fixed.md b/newsfragments/2769.fixed.md deleted file mode 100644 index d575dd2a932..00000000000 --- a/newsfragments/2769.fixed.md +++ /dev/null @@ -1 +0,0 @@ -Fix truncation of `isize` values to `c_long` in `PySlice::new`. diff --git a/newsfragments/2772.fixed.md b/newsfragments/2772.fixed.md deleted file mode 100644 index cf7b7986d38..00000000000 --- a/newsfragments/2772.fixed.md +++ /dev/null @@ -1 +0,0 @@ -Fix soundness issue with FFI definition `PyUnicodeDecodeError_Create` on PyPy leading to indeterminate behaviour (typically a `TypeError`). diff --git a/newsfragments/2776.added.md b/newsfragments/2776.added.md deleted file mode 100644 index 6166ef1df7e..00000000000 --- a/newsfragments/2776.added.md +++ /dev/null @@ -1 +0,0 @@ -Add `abi3-py311` feature. diff --git a/newsfragments/2784.changed.md b/newsfragments/2784.changed.md deleted file mode 100644 index 74c0428d9b4..00000000000 --- a/newsfragments/2784.changed.md +++ /dev/null @@ -1 +0,0 @@ -Automatically generate `__text_signature__` for all Python functions created using `#[pyfunction]` and `#[pymethods]`. diff --git a/newsfragments/2788.added.md b/newsfragments/2788.added.md deleted file mode 100644 index 2c744cef929..00000000000 --- a/newsfragments/2788.added.md +++ /dev/null @@ -1 +0,0 @@ -Define `_PyErr_ChainExceptions()` FFI for CPython. diff --git a/newsfragments/2795.changed.md b/newsfragments/2795.changed.md deleted file mode 100644 index b78efb63e5f..00000000000 --- a/newsfragments/2795.changed.md +++ /dev/null @@ -1 +0,0 @@ -Accept any iterator in `PySet::new` and `PyFrozenSet::new`. diff --git a/newsfragments/2796.changed.md b/newsfragments/2796.changed.md deleted file mode 100644 index 6d50956d179..00000000000 --- a/newsfragments/2796.changed.md +++ /dev/null @@ -1 +0,0 @@ -Mixing cfgs and pyo3 attributes on struct fields will now work \ No newline at end of file diff --git a/newsfragments/2800.fixed.md b/newsfragments/2800.fixed.md deleted file mode 100644 index 6a5b8503367..00000000000 --- a/newsfragments/2800.fixed.md +++ /dev/null @@ -1 +0,0 @@ -Allow functions taking `**kwargs` to accept keyword arguments which share a name with a positional-only argument (as permitted by PEP 570). diff --git a/newsfragments/2811.added.md b/newsfragments/2811.added.md deleted file mode 100644 index 6324253291d..00000000000 --- a/newsfragments/2811.added.md +++ /dev/null @@ -1 +0,0 @@ -Add FFI definitions `PyVectorcall_NARGS` and `PY_VECTORCALL_ARGUMENTS_OFFSET` for PyPy 3.8 and up. diff --git a/newsfragments/2811.fixed.md b/newsfragments/2811.fixed.md deleted file mode 100644 index 0011182c828..00000000000 --- a/newsfragments/2811.fixed.md +++ /dev/null @@ -1 +0,0 @@ -Fix unresolved symbol for `PyObject_Vectorcall` on PyPy 3.9 and up. diff --git a/newsfragments/2827.added.md b/newsfragments/2827.added.md deleted file mode 100644 index 4bd084ae91d..00000000000 --- a/newsfragments/2827.added.md +++ /dev/null @@ -1 +0,0 @@ -Add `PyList::get_item_unchecked` for PyPy. diff --git a/newsfragments/2838.changed.md b/newsfragments/2838.changed.md deleted file mode 100644 index d459d239746..00000000000 --- a/newsfragments/2838.changed.md +++ /dev/null @@ -1 +0,0 @@ -Re-enable `PyFunction` on when building for abi3 or PyPy. diff --git a/newsfragments/2842.fixed.md b/newsfragments/2842.fixed.md deleted file mode 100644 index 2bb66b11831..00000000000 --- a/newsfragments/2842.fixed.md +++ /dev/null @@ -1 +0,0 @@ -Fix memory leak in `PyCFunction::new_closure`. diff --git a/newsfragments/2843.removed.md b/newsfragments/2843.removed.md deleted file mode 100644 index bd7d399b954..00000000000 --- a/newsfragments/2843.removed.md +++ /dev/null @@ -1 +0,0 @@ -Remove all functionality deprecated in PyO3 0.16. diff --git a/newsfragments/2849.packaging.md b/newsfragments/2849.packaging.md deleted file mode 100644 index 62084844da7..00000000000 --- a/newsfragments/2849.packaging.md +++ /dev/null @@ -1 +0,0 @@ -Relax dependency on Rust crate `indexmap` to cover `>= 1.6, < 2` diff --git a/newsfragments/2875.changed.md b/newsfragments/2875.changed.md deleted file mode 100644 index b2f82e4b433..00000000000 --- a/newsfragments/2875.changed.md +++ /dev/null @@ -1 +0,0 @@ -Update `memoffset` to 0.8 and relax `hashbrown` version constraint to allow 0.13.x diff --git a/newsfragments/2879.changed.md b/newsfragments/2879.changed.md deleted file mode 100644 index 42c5287a3e9..00000000000 --- a/newsfragments/2879.changed.md +++ /dev/null @@ -1 +0,0 @@ -Improve `derive(FromPyObject)` to apply `intern!` when applicable to `#[pyo3(item)]`. diff --git a/pyo3-build-config/Cargo.toml b/pyo3-build-config/Cargo.toml index 3f519eabb3f..5aa756941a5 100644 --- a/pyo3-build-config/Cargo.toml +++ b/pyo3-build-config/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pyo3-build-config" -version = "0.17.3" +version = "0.18.0" description = "Build configuration for the PyO3 ecosystem" authors = ["PyO3 Project and Contributors "] keywords = ["pyo3", "python", "cpython", "ffi"] diff --git a/pyo3-ffi/Cargo.toml b/pyo3-ffi/Cargo.toml index 846cda6fe6b..80bf3eb8100 100644 --- a/pyo3-ffi/Cargo.toml +++ b/pyo3-ffi/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pyo3-ffi" -version = "0.17.3" +version = "0.18.0" description = "Python-API bindings for the PyO3 ecosystem" authors = ["PyO3 Project and Contributors "] 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.17.3", features = ["resolve-config"] } +pyo3-build-config = { path = "../pyo3-build-config", version = "0.18.0", features = ["resolve-config"] } diff --git a/pyo3-macros-backend/Cargo.toml b/pyo3-macros-backend/Cargo.toml index 8669d2148d0..3ff76d84273 100644 --- a/pyo3-macros-backend/Cargo.toml +++ b/pyo3-macros-backend/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pyo3-macros-backend" -version = "0.17.3" +version = "0.18.0" description = "Code generation for PyO3 package" authors = ["PyO3 Project and Contributors "] keywords = ["pyo3", "python", "cpython", "ffi"] diff --git a/pyo3-macros/Cargo.toml b/pyo3-macros/Cargo.toml index 372ad78f025..661de9ca072 100644 --- a/pyo3-macros/Cargo.toml +++ b/pyo3-macros/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pyo3-macros" -version = "0.17.3" +version = "0.18.0" description = "Proc macros for PyO3 package" authors = ["PyO3 Project and Contributors "] 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.56", features = ["full", "extra-traits"] } -pyo3-macros-backend = { path = "../pyo3-macros-backend", version = "=0.17.3" } +pyo3-macros-backend = { path = "../pyo3-macros-backend", version = "=0.18.0" } diff --git a/pyproject.toml b/pyproject.toml index e9b46d0698a..e62881d25e1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,7 @@ exclude = ''' [tool.towncrier] filename = "CHANGELOG.md" -version = "0.17.3" +version = "0.18.0" start_string = "\n" template = ".towncrier.template.md" title_format = "## [{version}] - {project_date}"