Commit Graph

5284 Commits

Author SHA1 Message Date
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
bors[bot] ebd417c9cc
Merge #3044
3044: Add `PyTuple::to_list` r=davidhewitt a=davidhewitt

Companion to #3043. I've included benchmarks which suggests that this method is indeed about 25% faster on my machine.

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-03-18 21:43:37 +00:00
bors[bot] 86b88d0088
Merge #3056
3056: ci: pin syn to 1.0 for MSRV r=davidhewitt a=davidhewitt

Looks like syn 2.0 requires Rust 1.56 - it'll be interesting for us to update to this one day, but not quite yet!

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-03-18 21:03:22 +00:00
David Hewitt 91afc7dc89 ci: pin syn to 1.0 for MSRV 2023-03-18 20:50:24 +00:00
David Hewitt 2c11b25fee Add `PyTuple::to_list` 2023-03-18 14:44:45 +00:00
Will Stott b05795307c Test static __getitem__ as well as __len__ 2023-03-18 13:56:51 +00:00
Will Stott bcdb17db5b Fix compile error when trying to use static slot methods 2023-03-18 11:16:52 +00:00
messense 79a70f3923
Improve default values for str, numbers and bool in `text_signature` 2023-03-16 11:06:51 +08:00
bors[bot] 658bc6bb7c
Merge #3049
3049: Add Blog post in Articles and other media section  r=messense a=AdilZouitine

Hi there 👋,

This pull request adds a link to a blog post in the PyO3 README under the "Articles and other media" section. The blog post, titled "How we extended the River stats module with Rust using PyO3," details our experience in utilizing PyO3 to improve the performance of the River library's stats module.




Co-authored-by: Adil Zouitine <adilzouitinegm@gmail.com>
2023-03-15 23:31:20 +00:00
Adil Zouitine bb9c54c09b
Update README.md
Add How we extended the River stats module with Rust using PyO3 blog post
2023-03-15 14:18:06 +01:00
bors[bot] b711e983ba
Merge #3040
3040: mangle exported functions for PyPy r=adamreichold a=mattip

Continuation of #3031. This [turned up](https://github.com/pypy/binary-testing/actions/runs/4390086363/jobs/7688256133#step:6:179) in the run of PyPy 3.10 HEAD against PyO3 HEAD. Should I add a new news fragment or is the one from #3031 sufficient?

Co-authored-by: Matti Picus <matti.picus@gmail.com>
2023-03-15 09:53:08 +00:00
Matti Picus a7cc5952c7
Conditionally mangle the function name
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-03-14 09:21:35 +11:00
bors[bot] 2823ab3944
Merge #3038
3038: Add note about garbage collection on PyPy r=davidhewitt a=adriangb

Closes #3005

Co-authored-by: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>
2023-03-12 23:36:35 +00:00
Adrian Garcia Badaracco 626a67ca49 Add note about garbage collection on PyPy 2023-03-12 23:35:47 +00:00
bors[bot] 11c8d0efe7
Merge #3043
3043: `PyList::as_tuple()` -> `PyList::to_tuple()` r=mejrs a=davidhewitt

As discussed as a follow-up to #3042 

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-03-12 22:02:37 +00:00
David Hewitt d3f5fed416 `PyList::as_tuple()` -> `PyList::to_tuple()` 2023-03-12 16:27:15 +00:00
bors[bot] 30521c853d
Merge #3042
3042: add `as_tuple()` method to `PyList` r=davidhewitt a=samuelcolvin

From [benchmarks](25fcf98e12/benches/main.rs (L165-L192)), this is significantly faster than `PyTuple::new(py, the_list)`:

```
test list_as_tuple_direct        ... bench:         299 ns/iter (+/- 51)
test list_as_tuple_iterate       ... bench:         521 ns/iter (+/- 41)
```


Co-authored-by: Samuel Colvin <s@muelcolvin.com>
2023-03-12 13:56:01 +00:00
Samuel Colvin a6c2695c7f
revert .gitignore change 2023-03-12 13:54:06 +00:00
Samuel Colvin b388f79a5f
add fragment 2023-03-12 12:46:59 +00:00
Samuel Colvin bf500edd16
add as_tuple() method to PyList 2023-03-12 12:42:59 +00:00
Matti Picus 0f1ff1d852 mangle exported functions for PyPy 2023-03-12 08:40:12 +11:00
bors[bot] 4b0b9b91a3
Merge #3036
3036: fix const-ness of some FFI name & doc members r=adamreichold a=davidhewitt

I just noticed that these are [`*const` since Python 3.7](007d7ff73f (diff-830b405713d1c40982ffa918864e39c40c1b318d79b8dd2b523646dc3bd18b52)).

This might break existing compiles, so will not include this in 0.18.2.

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-03-10 17:12:15 +00:00
David Hewitt fbebc285c0 fix const-ness of some FFI name & doc members 2023-03-10 16:02:52 +00:00
bors[bot] 550473fb1d
Merge #3031
3031: mangle exported functions for PyPy r=davidhewitt a=mattip

I run HEAD of PyO3 with HEAD of some PyPy branches, and noticed that the py3.10 branch (which implements python3.10) [fails to properly build](https://github.com/pypy/binary-testing/actions/runs/4334873617/jobs/7569059852#step:6:179). The failure was a missing export:
```
 /home/runner/work/binary-testing/binary-testing/pyo3/src/exceptions.rs:715: \
    undefined reference to `PyExc_EncodingWarning'
          collect2: error: ld returned 1 exit status
```

So I grepped around in the code for `Py_3_10` to see what new functions were added and found a few that needed PyPy-specific exports.

Co-authored-by: Matti Picus <matti.picus@gmail.com>
2023-03-10 09:39:54 +00:00
bors[bot] dd6498142f
Merge #3014
3014: feat: add #[pyo3(get, set)] for Cell r=davidhewitt a=AntoineRR

This fixes #2659.
The types for which `#[pyo3(get, set)]` should now work are `Cell`, `Arc` and `Box`.

There is one issue regarding `Box`, the implementation of `FromPyObject` conflicts with another one. I could not find what the issue was, especially since the other implementations for `Arc` and `Cell` work as expected. The related code and test has been commented out for now. Maybe someone could help me fix this issue if I don't figure it out myself? There is also the possibility to remove the implementation for `Box` of course.


Co-authored-by: Antoine Romero-Romero <ant.romero2@orange.fr>
2023-03-10 06:13:28 +00:00
bors[bot] b8bf93bce0
Merge #3032
3032: fix clippy and ui tests for Rust 1.68 r=adamreichold a=davidhewitt

The usual 😄 

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-03-10 05:00:29 +00:00
David Hewitt cd36c6fc21 fix clippy and ui tests for Rust 1.68 2023-03-09 23:41:26 +00:00
Matti Picus 232f9fb8ab add newsfragment 2023-03-10 10:16:24 +11:00
Antoine Romero-Romero a629e8267a feat: add #[pyo3(get, set)] for Cell 2023-03-09 23:09:30 +00:00
Matti Picus 8446414f3b mangle exported functions for PyPy 2023-03-10 07:27:38 +11:00
bors[bot] 59bbb40a35
Merge #3025
3025: Explain that pyo3-ffi-check is part of our CI now. r=messense a=adamreichold



Co-authored-by: Adam Reichold <adam.reichold@t-online.de>
2023-03-09 01:10:08 +00:00
Adam Reichold b63f9831ad Explain that pyo3-ffi-check is part of our CI now. 2023-03-08 16:08:27 +01:00
bors[bot] d31fa297c5
Merge #3019
3019: Use stable toolchain for Valgrind job as version 3.20 should handle the DWARF version. r=adamreichold a=adamreichold



Co-authored-by: Adam Reichold <adam.reichold@t-online.de>
2023-03-07 06:13:31 +00:00
Adam Reichold a913be22dc Use stable toolchain for Valgrind job as version 3.20 should handle the DWARF version. 2023-03-06 23:34:13 +01:00
bors[bot] 713c02a910
Merge #3009
3009: Remove stale references to tox.ini from template substitution scripts. r=messense a=adamreichold

Closes #3008 

Co-authored-by: Adam Reichold <adam.reichold@t-online.de>
2023-03-05 08:21:29 +00:00
Adam Reichold 39d19113fa Remove stale references to tox.ini from template substitution scripts. 2023-03-05 09:17:34 +01:00
bors[bot] c28edd0a81
Merge #2993
2993: fix `non_snake_case` lint for `#[pyfunction]` generated code r=davidhewitt a=davidhewitt

As promised in #2990 

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-02-28 08:49:13 +00:00
David Hewitt 7a2b1f0e13 fix `non_snake_case` lint for `#[pyfunction]` generated code 2023-02-28 08:44:17 +00:00
bors[bot] 794755c579
Merge #2990 #2991
2990: Fix `clippy::redundant_closure` lint firing for pyfunction defaults r=adamreichold a=davidhewitt

Fixes #2988

I'll push a follow-up for the FIXME as a separate PR.

2991: unpin 3.11 ci jobs r=adamreichold a=davidhewitt

With Python 3.11.2 released for a couple weeks now, I think #2817 is probably not an issue in CI any more.

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-02-28 05:11:22 +00:00
David Hewitt 0ef5531cbd unpin 3.11 ci jobs 2023-02-27 22:25:07 +00:00
David Hewitt 226bf97ec0 Fix `clippy::redundant_closure` lint firing for pyfunction defaults 2023-02-27 22:10:06 +00:00
bors[bot] 410bb15d71
Merge #2982
2982: explain STATUS_DLL_NOT_FOUND r=adamreichold a=mejrs

I had someone ask me this today, and googling for it I found various other places where this was asked, with no (good) answers. 

Co-authored-by: mejrs <59372212+mejrs@users.noreply.github.com>
2023-02-24 17:13:38 +00:00
mejrs db16580b63 Make changes 2023-02-23 12:36:54 +01:00
Adam Reichold 9534749d8b Add GILProtected synchronization primitive replacement and use it for LazyTypeObjectInner. 2023-02-23 09:38:02 +01:00
mejrs 90ce52175f explain STATUS_DLL_NOT_FOUND 2023-02-22 23:30:19 +01:00
bors[bot] bbaceb88b4
Merge #2899
2899: RFC: Provide a special purpose FromPyObject impl for byte slices r=davidhewitt a=adamreichold

This enables efficiently and safely getting a byte slice from either bytes or byte arrays.

The main issue I see here is discoverability, i.e. should this be mention in the docs of `PyBytes` and `PyByteArray` or in the guide?

It is also not completely clear whether this really _fixes_ the issue.

Closes #2888 

Co-authored-by: Adam Reichold <adam.reichold@t-online.de>
2023-02-22 22:13:56 +00:00
bors[bot] 7cffc92e69
Merge #2979
2979: allow `create_exception!` to place the exception in a `dotted.module` r=adamreichold a=davidhewitt

Closes #2946 

Credit fully to `@BlueGlassBlock`

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-02-22 21:24:21 +00:00
Adam Reichold 0a48859fc4 Make tests of Cow::<[u8]> compatible with older Python versions by using native code instead inline Python. 2023-02-22 22:12:35 +01:00