Commit Graph

630 Commits

Author SHA1 Message Date
Chris Laplante 3b94f4b70c
Add `anyhow-integration` feature which implements From<anyhow::Error> for PyErr (#1822)
* Add 'anyhow' feature which provides simple From<anyhow::Error> for PyErr impl

This makes it possible to use anyhow::Result<T> as the return type for
methods and functions exposed to Python.

The current implementation just stringifies the anyhow::Error before
shoving it into a PyRuntimeError. Conversion back to the anyhow::Error
is not possible, but it is better than nothing.

Signed-off-by: Chris Laplante <chris.laplante@agilent.com>

* Document `anyhow` feature in the guide

Signed-off-by: Chris Laplante <chris.laplante@agilent.com>

* update changelog to document anyhow feature

* WIP adding tests

* Finish up anyhow feature

* Fix formatting

* Fix tests

* Fix tests

* Apply review suggestions

Co-authored-by: Bruno Kolenbrander <59372212+mejrs@users.noreply.github.com>
Co-authored-by: mejrs <brunokolenbrander@hotmail.com>
2021-10-17 07:54:29 +01:00
Ashley Anderson a21e57a9d3 Fix additional tests after trybuild update 2021-10-11 20:52:24 -04:00
Bruno Kolenbrander 49570db3fc
chore: pin trybuild version (#1906)
chore: pin trybuild version to 1.0.49
2021-10-10 17:22:29 +02:00
mejrs c78b239586 Fix import 2021-10-03 02:30:13 +02:00
mejrs 22b9519f89 Avoid calling IntoIter on array in msrv 2021-10-03 02:09:53 +02:00
mejrs 31589f09e3 Skip pymethods hygiene on `multiple-pymethods` 2021-10-03 01:41:22 +02:00
mejrs af67acb644 Fix ci and add more pymodule tests 2021-10-02 21:04:22 +02:00
mejrs e3477c3cb7 Add to and restructure hygiene tests 2021-10-02 20:44:32 +02:00
David Hewitt c986b5d4ae
Merge pull request #1889 from davidhewitt/py310
packaging: formal support for Python 3.10
2021-09-29 19:36:52 +01:00
David Hewitt 03ba4a5597 ffi: use _Py_NewRef for clarity 2021-09-29 08:02:08 +01:00
David Hewitt 9e80f3dfdd pep 604: use `T | U` instead of `Union[T, U]` in messaging 2021-09-24 22:46:25 +01:00
David Hewitt 9fa0abe85d
Merge pull request #1864 from davidhewitt/pymethods-protos
pymethods: add support for protocol methods
2021-09-24 22:22:16 +01:00
David Hewitt 179b5d1f47 pymethods: fix support for MSRV 2021-09-18 16:42:02 +01:00
David Hewitt 592c98c722 pymethods: disable protocols with multiple-pymethods for now 2021-09-18 13:08:24 +01:00
David Hewitt a551b005b4 pymethods: finish support for number protocol 2021-09-18 12:59:25 +01:00
David Hewitt c2d78ca76e pymethods: faster compilation for protos, tidy ups 2021-09-18 09:49:05 +01:00
David Hewitt 43eb762346 pymethods: support most numerical methods 2021-09-18 00:31:17 +01:00
David Hewitt 70d829de66 gil: try to initialize threads on Python 3.6 if possible 2021-09-17 08:48:21 +01:00
David Hewitt 92e2156161 pymethods: support inplace numerical operations 2021-09-17 08:13:54 +01:00
David Hewitt b544b5a6d7 pymethods: support iter and async protocols 2021-09-17 08:13:54 +01:00
David Hewitt 8408328cb3 pymethods: add support for protocol methods 2021-09-17 08:13:54 +01:00
mejrs 4cd9f4b570 import FromPyObject into crate root 2021-09-14 14:07:23 +02:00
mejrs d6973b1b6a clean up lib.rs 2021-09-13 22:58:15 +02:00
mejrs 68cba78a44
chore: update rust 1.55 (#1865)
* chore: update rust 1.55

* move test to 1.55 only

* make ci happy

* make ci happy

* make ci happy

* make ci happy

* make clippy happy

* make ci happy

* formatting
2021-09-12 18:07:24 +01:00
David Hewitt f4c834f5fc
Merge pull request #1843 from PyO3/pymethods_hygiene
more macro hygiene cleanup: test #[pymethods] and more arg parsing and protos
2021-08-29 11:26:10 +01:00
Georg Brandl 381eb9c501
Apply suggestions from code review
Co-authored-by: mejrs <59372212+mejrs@users.noreply.github.com>
2021-08-29 08:30:05 +02:00
David Hewitt 95a11d0725
Merge pull request #1842 from PyO3/frompyobject_hygiene
more macro hygiene cleanup: test the FromPyObject derive macro
2021-08-29 07:15:16 +01:00
David Hewitt 604b28451b
Merge pull request #1841 from PyO3/exception_hygiene
more macro hygiene cleanup: test the exception macros
2021-08-29 07:14:36 +01:00
David Hewitt f76535fd07 pyo3-macros-backend: support macros inside doc attributes 2021-08-28 22:47:20 +01:00
Georg Brandl 6f75fc8eb7 more macro hygiene cleanup: test #[pymethods] and more arg parsing and protos 2021-08-28 18:05:32 +02:00
Georg Brandl 585487c3c1 more macro hygiene cleanup: test the FromPyObject derive macro 2021-08-28 16:42:29 +02:00
Georg Brandl db00a34a56 more macro hygiene cleanup: test the exception macros 2021-08-28 15:45:49 +02:00
David Hewitt 313610993a pyo3-macros-backend: more tests for macro hygiene 2021-08-28 10:28:27 +01:00
Georg Brandl 2979fb8268 tests: fix new clippy warning (does not like Foo::foo) 2021-08-23 15:47:09 +02:00
David Hewitt 0613b5a8f8
Merge pull request #1805 from mejrs/proc_macro_hygiene
Test proc macro hygiene for `#[pyclass]` macro.
2021-08-18 19:08:41 +01:00
mejrs f79420dabd remove shadowing 2021-08-17 21:38:28 +02:00
mejrs 3be3af4121 fix extends param 2021-08-17 15:19:19 +02:00
mejrs bce5100dc3 use macro to shadow 2021-08-17 15:16:03 +02:00
David Hewitt 37d39aa83a
Merge pull request #1751 from davidhewitt/pyany-py
pyany: add PyAny::py()
2021-08-17 14:10:16 +01:00
mejrs 370968b595 test macro hygiene for pyclass 2021-08-16 16:32:11 +02:00
Gregory Szorc 410c9f13c9 macros: raise AttributeError on property deletion requests
The setter function will receive a NULL value on deletion requests.
This wasn't properly handled before, leading to a panic.

The new code raises AttributeError in this scenario instead.

A test for the behavior has been added. Documentation has also
been updated to reflect the behavior.
2021-08-13 21:01:00 -07:00
David Hewitt ebada76ae3 pyany: add PyAny::py() 2021-08-13 08:00:13 +01:00
David Hewitt b6e8da104d coverage: also run compile_error tests 2021-08-07 22:45:07 +01:00
R2D2 d809e50c9b Replaced require_gil with Python::with_gil in test_frompyobject.rs. Removed all unsafe code from macro generated code. Two other small fixes 2021-08-02 09:49:13 +02:00
R2D2 3cfc76ae93 Reworked struct error messages to use the of an error rather than concatenating all error messages 2021-07-31 23:21:07 +02:00
R2D2 403d882d6c Merge branch 'main' of https://github.com/PyO3/pyo3 into enhanced_extract_type_errors 2021-07-31 21:21:10 +02:00
David Hewitt ee9a1678d5 rust: updates for rust & clippy 1.54 2021-07-31 08:19:38 +01:00
David Hewitt d11943ab6d macros-backend: don't error on #[doc(hidden)] 2021-07-08 23:41:24 +01:00
mejrs c07c5a4c93 Add full path for PyCell 2021-07-03 07:51:18 +01:00
scalexm 7e8eeec02f Add a test 2021-06-25 00:18:53 +02:00