Commit graph

5188 commits

Author SHA1 Message Date
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
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
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
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
David Hewitt 4f34f0e094 readme: add new pyo3 article 2023-04-12 07:55:24 +01:00
bors[bot] b2e10f5e85
Merge #3096
3096: docs: fix migration guide entry for pyproto r=adamreichold a=davidhewitt

A sort of follow-up to #3082 .

While I don't think we need to pander to training limitations of various LLMs, I did notice that I erroneously referred to a nonexistent trait `PyBasicProtocol`, which I believe should have been [`PyObjectProtocol`](https://docs.rs/pyo3/0.15.2/pyo3/class/basic/trait.PyObjectProtocol.html).

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-04-12 06:53:58 +00:00
David Hewitt 80d95f9134 docs: fix migration guide entry for pyproto 2023-04-11 21:23:05 +01:00
bors[bot] b4d4904d71
Merge #3087
3087: PEP 623: wstr, wstr_length, state changes r=adamreichold a=ijl

https://peps.python.org/pep-0623/

	Following members are removed from the Unicode structures:

	    wstr
	    wstr_length
	    state.compact
	    state.ready

Note state.compact is still present as of v3.12.0a7.

state.interned has changed width from 2 to 1 bits.

Co-authored-by: ijl <ijl@mailbox.org>
2023-04-11 14:04:16 +00:00
ijl 88b46a7029 PEP 623: wstr, wstr_length, state changes
https://peps.python.org/pep-0623/

	Following members are removed from the Unicode structures:

	    wstr
	    wstr_length
	    state.compact
	    state.ready

Note state.compact is still present as of v3.12.0a7.

state.interned has changed width from 2 to 1 bits.
2023-04-11 12:51:42 +00:00
bors[bot] 275e66112d
Merge #3088
3088: Define _PyDict_Contains_KnownHash() FFI for CPython 3.10 or later r=messense a=ijl



Co-authored-by: ijl <ijl@mailbox.org>
2023-04-10 08:11:28 +00:00
bors[bot] 579d510916
Merge #3092
3092: Fix redundant imports in doc tests thereby fixing the careful CI job. r=adamreichold a=adamreichold



Co-authored-by: Adam Reichold <adam.reichold@t-online.de>
2023-04-10 06:35:47 +00:00
Adam Reichold 48f79718f9 Fix redundant imports in doc tests thereby fixing the careful CI job. 2023-04-10 08:09:06 +02:00
ijl 6ee2174fec Define _PyDict_Contains_KnownHash() FFI for CPython 3.10 or later 2023-04-09 14:36:42 +00:00
bors[bot] 77fc6e6734
Merge #3067
3067: docs: show pattern for self.__class__.__name__ in __repr__ r=adamreichold a=wjones127

It took me a little while to figure out this pattern in PyO3, so I thought it would be a good addition to the guide.

It's not the cleanest pattern, so would welcome suggestions on how to make it shorter or easier.

Co-authored-by: Will Jones <willjones127@gmail.com>
2023-03-30 09:00:31 +00:00
Will Jones 52a0378e56 docs: show pattern for self.__class__.__name__ in __repr__
Co-authored-by: Bruno Kolenbrander <59372212+mejrs@users.noreply.github.com>
2023-03-30 10:59:41 +02:00
messense 57dbc94293
Improve default value for None in text_signature 2023-03-29 10:14:44 +08:00
bors[bot] 90d50da506
Merge #3071
3071: fix typo DateType -> DateTimeType, fixes #3069 r=adamreichold a=sollyucko

This should fix #3069 AKA https://stackoverflow.com/questions/75857300/tell-if-object-isinstance-of-pydatetime-or-pydate. I've added an entry in newsfragments and I've added some regression tests in test_datetime.rs.

Co-authored-by: Solomon Ucko <solly.ucko@gmail.com>
2023-03-28 16:46:42 +00:00
Solomon Ucko 7e2f732d7a fix typo DateType -> DateTimeType, fixes #3069 2023-03-28 18:45:39 +02:00
bors[bot] ba6261c8e7
Merge #3015
3015: Implement wrapper for `PyASCIIObject.state` bitfield accesses r=davidhewitt a=decathorpe

This is a first draft of my attempt to fix #1824 "properly" by writing a C wrapper for the `PyASCIIObject.state` bitfield accesses, as proposed here: https://github.com/PyO3/pyo3/issues/1824#issuecomment-1406909504

---

The original argument for making these functions `unsafe` is still valid, though - bitfield memory layout is not guaranteed to be stable across different C compilers, as it is "implementation defined" in the C standard. However, short of having CPython upstream provide non-inlined public functions to access this bitfield, this is the next best thing, as far as I can tell.

I've removed the `#[cfg(target_endian = "little")]` attributes from all things that are un-blocked by fixing this issue on big-endian systems, except for three tests, which look like expected failures considering that they do not take bit/byte order into account (for example, when writing to the bitfield).

- `ffi::tests::ascii_object_bitfield`
- `types::string::tests::test_string_data_ucs2_invalid`
- `types::string::tests::test_string_data_ucs4_invalid`

All other tests now pass on both little-endian and big-endian systems.

---

I am aware that some parts of this PR are probably not in a state that's acceptable for merging as-is, which is why I'm filing this as a draft. Feedback about how to better integrate this change with pyo3-ffi would be great. :)

In particular, I'm unsure whether the `#include` statements in the C files are actually correct across different systems. I have only tested this on Fedora Linux so far.

I'm also open to changing the names of the C functions that are implemented in the wrapper. For now I chose the most obvious names that shouldn't cause collisions with other symbols.

Co-authored-by: Fabio Valentini <decathorpe@gmail.com>
2023-03-28 07:27:02 +00:00
bors[bot] d2c6873c0f
Merge #3072
3072: CI: Pin `inventory` to `0.3.4` in MSRV job r=davidhewitt a=messense

Newer `inventory` requires `ctor` 0.2.0.

Co-authored-by: messense <messense@icloud.com>
2023-03-28 05:20:41 +00:00
messense 368664c731
CI: Pin inventory to 0.3.4 in MSRV job 2023-03-28 13:09:58 +08:00
Fabio Valentini 40d6d4797f
Add wrapper for PyASCIIObject state bitfield accesses based on bindgen 2023-03-26 17:11:01 +02:00