Commit graph

5206 commits

Author SHA1 Message Date
David Hewitt dd24c9ea71 remove Python::acquire_gil 2023-05-09 09:39:23 +02:00
Adam Reichold 3c634dd9a9 Add migration guide entry on replacing acquire_gil by with_gil. 2023-05-09 09:39:23 +02:00
bors[bot] 6281b47954
Merge #3004
3004: Unwrap dynamic error types when inner is simple `PyErr` r=davidhewitt,adamreichold,mejrs a=BlueGlassBlock

This is the first part of suggested improvements in #2998.

This change will make bubbled `PyErr` wrapped in `eyre::Report` / `anyhow::Error` bubble up unchanged, instead of being wrapped in a `PyRuntimeError`.

Co-authored-by: BlueGlassBlock <blueglassblock@outlook.com>
2023-05-09 06:18:33 +00:00
BlueGlassBlock fdd43d0685 feat: unwrap dyn Err when inner is simple PyErr 2023-05-09 07:17:10 +01:00
bors[bot] 8ab3f5fc47
Merge #3141
3141: Add BaseExceptionGroup for Python >= 3.11 r=adamreichold a=adriangb

Not sure if this is totally off base, but it looks like it may be this easy to add support for ExceptionGroup?

Co-authored-by: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>
2023-05-08 08:39:21 +00:00
Adrian Garcia Badaracco 16d333f9d0
Add BaseExceptionGroup for Python >= 3.11 2023-05-07 15:08:43 -05:00
bors[bot] 1cdac4fde4
Merge #2980
2980: support `text_signature` on `#[new]` r=adamreichold a=davidhewitt

Closes #2866 

This is a breaking change for 0.19.0, because it starts autogenerating `text_signature` for `#[new]`. This could affect runtime behaviour if the user is relying on the class docs at runtime for some reason.

Guide & tests all updated accordingly.

`#[pyclass(text_signature = "...")]` is deprecated by this PR, however if it's set, it will be used in preference to `#[new]`.

(The signature / `text_signature` from `#[new]` will simply be ignored in this case. I figure that when users fix their deprecation warnings by removing `#[pyclass(text_signature = "...")]` then the `#[new]` signatures will start flowing properly, and this is good enough.)

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
Co-authored-by: Adam Reichold <adam.reichold@t-online.de>
2023-05-04 16:51:54 +00:00
Adam Reichold bd4b550495 Do not assert class text signature using the limited API before version 3.10 as we do not support it. 2023-05-04 18:28:43 +02:00
bors[bot] 22e77b0213
Merge #3131
3131: Extend lifetime of GIL token associated with PyRef(Mut). r=mejrs a=adamreichold



Co-authored-by: Adam Reichold <adam.reichold@t-online.de>
2023-05-04 11:46:09 +00:00
bors[bot] 6356acb2f9
Merge #3120
3120: feat: add #[pyo3(from_item_all)] for FromPyObject r=davidhewitt a=BlueGlassBlock

This PR addresses #3112 by implementing ~~`#[pyo3(item_all)]`~~ `#[pyo3(from_item_all)]`.

Co-authored-by: BlueGlassBlock <blueglassblock@outlook.com>
2023-05-04 07:10:21 +00:00
David Hewitt 8bd17f02c7 support text_signature on #[new] 2023-05-04 07:15:11 +01:00
bors[bot] 157e0b4ad6
Merge #3129
3129: Fix a crate doc link for IterNextOutput r=adamreichold a=cfour2

This should fix the links [1](https://docs.rs/pyo3/0.18.3/pyo3/pyclass/enum.IterNextOutput.html#:~:text=See%20PyIterProtocol%20for%20an%20example.) and [2](https://pyo3.rs/v0.18.3/class/protocols#:~:text=PyO3%20provides%20the-,IterNextOutput,-enum%20to%20both).

They originally point to, which do not exist now:
1. https://docs.rs/pyo3/0.18.3/pyo3/pyclass/trait.PyIterProtocol.html
2. https://docs.rs/pyo3/0.18.3/pyo3/class/iter/enum.IterNextOutput.html

Co-authored-by: cfour2 <cfour2@protonmail.com>
2023-05-02 18:48:51 +00:00
cfour2 04f129f70f Refine the example for IterNextOutput
* Remove the (eventually) stale ref link;
* Typo: couter -> counter;
* Fix the formatting with `cargo fmt`;
2023-05-02 15:15:55 +08:00
cfour2 1ca1dc3ccb Copy an example for IterNextOutput from pytests with comments 2023-05-02 15:05:53 +08:00
cfour2 559b540b5c Fix a crate doc link for IterNextOutput 2023-05-02 15:05:53 +08:00
Adam Reichold 63a9093510 Extend lifetime of GIL token associated with PyRef(Mut). 2023-05-01 20:57:08 +02:00
bors[bot] f9cb5e5cb0
Merge #3130
3130: Make sure to upgrade pip before trying to install nox. r=adamreichold a=adamreichold



Co-authored-by: Adam Reichold <adam.reichold@t-online.de>
2023-05-01 16:35:08 +00:00
Adam Reichold b52730ac27 Make sure to upgrade pip before trying to install nox. 2023-05-01 18:13:49 +02:00
Adam Reichold ed997ed178 venv_backend syntax for set_minimal_package_versions nox session. 2023-05-01 17:53:43 +02:00
BlueGlassBlock f75ea3d93a
test: improve cov 2023-04-27 12:44:38 +08:00
BlueGlassBlock 28cc9e3f6c
chore: EOF ui test 2023-04-26 20:08:46 +08:00
BlueGlassBlock 158410fc77
fix: ui test stderr 2023-04-26 20:05:43 +08:00
BlueGlassBlock 1d6ab21781
fix: change to from_item_all 2023-04-26 19:47:07 +08:00
BlueGlassBlock c415d79bf7
test(ui): TRYBUILD=overwrite 2023-04-26 13:02:22 +08:00
BlueGlassBlock 5f4acd72d0
test: add ui tests 2023-04-26 12:48:12 +08:00
BlueGlassBlock f58f55dab4
doc: add news frags 2023-04-25 19:40:59 +08:00
BlueGlassBlock 30b2ed1d85
feat: add #[pyo3(item_all)] for FromPyObject 2023-04-25 19:37:05 +08:00
bors[bot] f060088792
Merge #3119
3119: Fix crate docs links in python_from_rust.md r=adamreichold a=xcharleslin

Thank you for contributing to pyo3!

Please consider adding the following to your pull request:
 - an entry for this PR in newsfragments - see [https://pyo3.rs/main/contributing.html#documenting-changes]
 - docs to all new functions and / or detail in the guide
 - tests for all new or changed functions

PyO3's CI pipeline will check your pull request. To run its tests
locally, you can run ```cargo xtask ci```. See its documentation
 [here](https://github.com/PyO3/pyo3/tree/main/xtask#readme).


Co-authored-by: xcharleslin <4212216+xcharleslin@users.noreply.github.com>
2023-04-25 04:23:38 +00:00
xcharleslin 512847257e
Fix crate docs links in python_from_rust.md 2023-04-24 15:21:08 -07:00
bors[bot] c55d1b6fb1
Merge #3116
3116: minor grammar fix in documentation r=adamreichold a=Walnut356



Co-authored-by: Walnut <39544927+Walnut356@users.noreply.github.com>
2023-04-23 07:27:03 +00:00
Walnut 24ab144a41
minor grammar fix in documentation 2023-04-23 02:05:51 -05:00
bors[bot] 3e21797a1d
Merge #3016
3016: implement Decimal to rust_decimal conversions r=adamreichold a=cardoe

Implement conversion between rust_decimal::Decimal and decimal.Decimal from Python's stdlib. The C API does not appear to be exposed on the Python side so we need to call into it via Python.

Implements #2774



Co-authored-by: Doug Goldstein <cardoe@cardoe.com>
2023-04-22 18:28:07 +00:00
Doug Goldstein 8e0bde14c9 implement Decimal to rust_decimal conversions
Implement conversion between rust_decimal::Decimal and decimal.Decimal
from Python's stdlib. The C API does not appear to be exposed on the
Python side so we need to call into it via Python.
2023-04-22 19:55:21 +02:00
bors[bot] d09402fd66
Merge #3115
3115: Update getting_started.md r=adamreichold a=jond01

Update Poetry command to Poetry groups syntax (1.2+).
https://python-poetry.org/docs/cli/#options-4:
> `--dev (-D`): Add package as development dependency. (**Deprecated**, use `-G dev` instead)

Co-authored-by: Jonathan Daniel <36337649+jond01@users.noreply.github.com>
2023-04-21 20:39:04 +00:00
Jonathan Daniel 3a9c6b175d
Update getting_started.md
Update Poetry command to Poetry groups syntax (1.2+).
https://python-poetry.org/docs/cli/#options-4
2023-04-21 23:19:57 +03:00
bors[bot] 9ca94a126b
Merge #3114
3114: Chores to keep the build system working r=adamreichold a=adamreichold



Co-authored-by: Adam Reichold <adam.reichold@t-online.de>
2023-04-21 16:10:59 +00:00
Adam Reichold 04d962e2ed Update UI tests for Rust 1.69.0. 2023-04-21 16:22:42 +02:00
Adam Reichold 67d4c7eb82 Pin regex to keep our MSRV support. 2023-04-21 16:08:42 +02:00
bors[bot] 2f8bf513b5
Merge #3097
3097: ci: use codecov coverage format r=davidhewitt a=davidhewitt

Newly supported on `cargo-llvm-cov` 0.5.12, might give some more detailed information.

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-04-19 07:17:41 +00:00
bors[bot] 7afab36e60
Merge #3111
3111: Rename sequence `.list()` and `.tuple()` to `.to_list()` and `.to_tuple()` r=adamreichold a=davidhewitt

As agreed in https://github.com/PyO3/pyo3/pull/3042#issuecomment-1465229510.

The motivation is that it is an emerging Rust convention for `to_x` to mean "a non-consuming conversion to type x which has some (small) overhead". E.g. `to_string`, `to_owned`.

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-04-19 03:30:31 +00:00
David Hewitt d8f7e6b41b ci: use codecov coverage format 2023-04-18 21:44:14 +01:00
David Hewitt eb4ba53251 Rename sequence .list() and .tuple() to .to_list() and .to_tuple() 2023-04-18 20:52:49 +01:00
bors[bot] f08098f9b9
Merge #3102
3102: Actually set target when running Clippy builds. r=davidhewitt a=adamreichold



Co-authored-by: Adam Reichold <adam.reichold@t-online.de>
2023-04-18 07:25:22 +00:00
Adam Reichold 654616ce50 Handle test code that is unused on wasm32. 2023-04-14 18:50:32 +02:00
Adam Reichold 452c971023 Do not test multiple-pymethods feature on WASI where it is not supported by the inventory crate. 2023-04-14 18:41:45 +02:00
Adam Reichold 2c1762949e Fix some Clippy warnings only visible in the CI. 2023-04-14 18:41:45 +02:00
Adam Reichold f981fded3f Actually set target when running Clippy builds. 2023-04-14 18:41:45 +02:00
bors[bot] 61ef8fec4f
Merge #3103
3103: update release notes for 0.18.3 r=davidhewitt a=davidhewitt



Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-04-13 21:49:01 +00:00
David Hewitt bfcc1f8c27 update release notes for 0.18.3 2023-04-13 22:47:55 +01:00
bors[bot] a0e285b497
Merge #3066 #3098
3066: Improve default value for `None` in `text_signature` r=davidhewitt a=messense

xref #2863

3098: readme: add new pyo3 article r=adamreichold a=davidhewitt

With thanks to `@ohadravid` for the great piece!

Co-authored-by: messense <messense@icloud.com>
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-04-12 07:40:50 +00:00