Commit Graph

5181 Commits

Author SHA1 Message Date
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
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
bors[bot] ebedcfb8b2
Merge #3050
3050: Improve default values for str, numbers and bool in `text_signature` r=davidhewitt a=messense

xref #2863

Co-authored-by: messense <messense@icloud.com>
2023-03-25 07:07:06 +00:00
bors[bot] e2bcca4771
Merge #3063
3063: update release notes for 0.18.2 r=davidhewitt a=davidhewitt

Changelog entry & cargo.toml changes from 0.18.2 

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-03-24 21:44:48 +00:00
David Hewitt e7e58ba51e update release notes for 0.18.2 2023-03-24 20:40:06 +00:00
bors[bot] e5e8c7a6d0
Merge #2975 #3022 #3023
2975: RFC: Add GILProtected synchronization primitive and use it for LazyTypeObjectInner. r=davidhewitt a=adamreichold

I would also like to use that type in rust-numpy and it seems we can avoid ~~both a manual unsafe impl and~~ a full blown mutex if we apply it to `LazyTypeObjectInner`.

One downside might be that it ties us closer to the GIL when we want to enable nogil experimentation, but on the other hand, it may also help by reifying the GIL usage. (This is currently limited to comments in unsafe code in rust-numpy for example.)

3022: Fix function name shadowing r=davidhewitt a=mejrs

Fixes https://github.com/PyO3/pyo3/issues/3017

3023: Emit a better error for bad argument names r=davidhewitt a=mejrs

This will emit a better error for code like 
```rust
#[pyfunction]
fn output([a,b,c]: [u8;3]) {}
```



Co-authored-by: Adam Reichold <adam.reichold@t-online.de>
Co-authored-by: mejrs <59372212+mejrs@users.noreply.github.com>
2023-03-23 08:04:11 +00:00
mejrs 1ecc71638d Emit a better error for bad argument names 2023-03-23 07:43:54 +00:00
mejrs 4966d93494 Fix function name shadowing 2023-03-23 07:33:14 +00:00
bors[bot] 28814f2978
Merge #3055
3055: Fix compile error when trying to use static slot methods, fixes: #3039 r=davidhewitt a=willstott101

Whilst having static slot methods is of dubious value in the first place, there's little reason not to support it by bringing the different function call macros more in-line with each other.

I had no idea which test file to use so I just made a new one... `test_methods.rs` has no slots in and the test files that do use slots seem to be specific to their protocol. Let me know if you'd like the test somewhere else.

Thanks!

Co-authored-by: Will Stott <willstott101@gmail.com>
2023-03-23 07:23:38 +00:00