Commit Graph

819 Commits

Author SHA1 Message Date
Adam Reichold 577570e8c4 Reduce visibility of CaptureStdErr type to avoid warnings on older toolchains. 2023-02-18 17:11:40 +01:00
David Hewitt c7cc48f8e4 use PyO3 types within LazyTypeObject 2023-02-18 09:06:36 +00:00
David Hewitt 00ddd21535 change PyModule::add_class to return an error if class creation fails 2023-02-14 22:08:35 +00:00
bors[bot] 864aee0916
Merge #2930
2930: add better error message for Python in signature r=adamreichold a=davidhewitt

Inspired by #2929, this just adds a better error message when `Python` arguments are accidentally included in the signature.

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-02-03 09:11:26 +00:00
David Hewitt 96efb0eda9 add better error message for Python in signature 2023-02-03 06:57:30 +00:00
Armin Ronacher 066880e7d5 Added support for PyErr_WriteUnraisable 2023-01-29 20:01:22 +00:00
Nate Kent f11290d314
Add additional unit test for GC traversal
Since we're just testing a bug during traversal, we don't actually have
to reap the object, we just have to make a reference cycle so that it's
traverse method is called.
2023-01-26 16:27:54 -08:00
mejrs 2052269aea Update rust 1.67 2023-01-26 21:44:05 +01:00
David Hewitt 586fed2c4b send errors in `__releasebuffer__` to `sys.unraisablehook` 2023-01-19 19:10:06 +00:00
David Hewitt 8f48d157d6 deprecate required arguments after option arguments without signature 2023-01-15 10:17:20 +00:00
bors[bot] 8af48bbb53
Merge #2796
2796: Forward cfgs on pyclass fields to the method defs r=davidhewitt a=mejrs

With this and the cfg_attr PR, I don't need cfg_eval at all anymore :)


- [x] needs some more tests

Co-authored-by: mejrs <>
2022-12-29 16:28:26 +00:00
mejrs 5198722dd9 Add test 2022-12-28 23:11:39 +01:00
Alex Gaynor 4875e4b6bf update URL in comment to point at correct place
The branch has drifted and those line ranges are no longer accurate.
2022-12-28 20:48:11 +01:00
David Hewitt f2608a923c remove functionality deprecated in 0.16 2022-12-28 12:23:53 +00:00
David Hewitt 5039fd746a add automatic text signature generation 2022-12-24 09:43:02 +00:00
David Hewitt 33871b7aea allow **kwargs to take arguments which conflict with positional-only parameters 2022-12-17 07:22:28 +00:00
David Hewitt f01b245d85 update ui tests for Rust 1.66 2022-12-16 20:56:15 +00:00
bors[bot] 08423557d4
Merge #2739
2739: error when `#[pyo3(signature = ())]` used on invalid methods r=davidhewitt a=davidhewitt

A follow-up to #2702 to reject some invalid applications of `#[pyo3(signature = (...))]` attribute, specifically on magic methods and getters / setters / class attributes.

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2022-11-22 19:41:27 +00:00
Georg Brandl 99c8dea30e Use Python::get_type() instead of PyTypeInfo::type_object()
The former needs one less import and uses a familiar object.
2022-11-20 15:16:18 +01:00
Georg Brandl 2a630a2a52 Fix being able to call arg-less `#[new]` with any args from Python
Fixes #2748
2022-11-20 08:25:19 +01:00
Georg Brandl c489809938 Py/PyAny: deprecate cast_as() in favor of downcast()
They are (practically) identical on PyAny, and `downcast()` is the more
useful name.
2022-11-18 07:00:40 +01:00
David Hewitt 00fc0358b9 error when `#[pyo3(signature = ())]` used on invalid methods 2022-11-17 08:28:34 +00:00
Bruno Kolenbrander 6766d9f93b
Merge pull request #2686 from dalcde/closure-name-doc
Support passing name and doc to new_closure.
2022-11-06 17:35:20 +01:00
messense 0e770a8458 Update ui tests for Rust 1.65.0 2022-11-04 06:35:30 +00:00
Dexter Chua 9201a7dd48 Support passing name and doc to PyCFunction::new_closure. Fixes #2665 2022-10-29 12:26:09 +08:00
David Hewitt 8e8b484169
add `#[pyo3(signature = (...))]` attribute (#2702) 2022-10-25 07:23:21 +01:00
David Hewitt 747d791f1f
introduce trampolines for methods (#2705) 2022-10-25 07:22:36 +01:00
David Hewitt 446c0e82f0
Merge pull request #2692 from mejrs/all
Implement get/set all on pyclass
2022-10-18 21:39:44 +01:00
mejrs 08c8b845aa Create better error spans/messages 2022-10-18 21:14:22 +02:00
mejrs d254134154 Implement get/set all on pyclass 2022-10-17 02:37:43 +02:00
Bruno Kolenbrander 4a04603c2c
Don't use intocallback in method macros (#2664)
* Don't use intocallback in method macros

Co-authored-by: mejrs <>
2022-10-16 10:35:58 +01:00
David Hewitt 8102ad1a1b rust: updates for 1.64 2022-09-22 21:03:34 +02:00
David Hewitt c5ba1f0632
pyclass: better error and explanation why lifetimes are disallowed (#2633)
* pyclass: better error and explanation why lifetimes are disallowed

* extend detail on lifetimes
2022-09-22 11:14:06 +02:00
David Hewitt c445eba28d pyfunction: fix compile error for Option<&T> argument with a default 2022-09-20 15:44:55 +02:00
Jonathan Coates 26a9603519 Some improvements to __richcmp__ on enums
- Implement __ne__ as well as __eq__.
 - Return NotImplemented when types cannot be converted, rather than
   throwing.
 - Compare the integer ids inside the __eq__/__ne__ implementation.
   Previously a match block was generated.
2022-09-16 15:30:56 +01:00
Ivan “CLOVIS” Canet d7c1a2906a
IntoPy and FromPyObject allow the retrieval of the type information 2022-09-06 21:30:36 +02:00
David Hewitt 5718adeec7 pyproto: remove deprecated feature 2022-09-06 08:38:44 +01:00
David Hewitt 9d543b3f4b pyfunction: fix from_py_with on Option<T> argument 2022-08-25 18:57:17 +01:00
David Hewitt 36ecadd69f ci: unpin serde, fixup nightly ui tests 2022-08-23 08:07:26 +01:00
David Hewitt d0492b7c72
Merge pull request #2570 from davidhewitt/pyclass-frozen-tidy
pyclass: tidy up frozen implementation
2022-08-21 09:35:51 +01:00
David Hewitt 24456f3f41 pyclass: tidy up frozen implementation 2022-08-21 08:21:06 +01:00
David Hewitt fd8026c7bb pyclass: add `sequence` option to implement `sq_length` 2022-08-20 07:14:26 +01:00
mejrs fc6121eafe Deprecate acquire_gil 2022-08-15 03:34:47 +02:00
David Hewitt c58ff7758c pypy: disable PyFunction 2022-08-13 17:51:10 +01:00
David Hewitt 987858f5fa ci: ui tests for 1.63 2022-08-12 07:26:29 +01:00
messense db177a07ad
Fix new clippy warnings in Rust 1.63.0 2022-08-12 11:50:23 +08:00
Ashley Anderson 5d88e1d1c4
Update PyTryFrom for PyMapping and PySequence to more accurately check types (#2477)
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2022-08-10 21:03:18 +01:00
David Hewitt 78ba70d2b4 pymodule: only allow initializing once per process 2022-08-09 19:52:25 +01:00
mejrs 984fdf57c7 Use Python:;with_gil in tests 2022-07-19 19:34:23 +02:00
David Hewitt d5e99b635d refactor: remove all 0.15 deprecations 2022-07-15 06:33:14 +01:00