Commit Graph

53 Commits

Author SHA1 Message Date
mejrs 984fdf57c7 Use Python:;with_gil in tests 2022-07-19 19:34:23 +02:00
mejrs 6f1cf1b662 Add more lints 2022-03-23 08:07:28 +01:00
David Hewitt 6af47c78f1 pymethods: more tests for magic methods 2022-02-16 07:42:25 +00:00
David Hewitt a9b98b7433 pymethods: __ipow__ always receive None on Python 3.7 2022-01-04 22:59:08 +00:00
Aviram Hassan 50659b6b02
`__ipow__` now supports modulo argument on Python 3.8+.
`pyo3-macros-backend` is now compiled with PyO3 cfgs to enable different magic method definitions based on version.
Add check for correct number of arguments on magic methods.
2022-01-03 09:53:56 +02:00
David Hewitt 6433d884fc dev: remove self dev dependency 2021-12-08 07:48:58 +00:00
David Hewitt 0e0e6f8bf5 pymethods: support protocols with `multiple-pymethods` feature 2021-10-23 00:07:35 +01:00
David Hewitt 212404bc23 pymethods: support __rtruediv__ and __rfloordiv__ 2021-10-17 08:33:46 +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 92e2156161 pymethods: support inplace numerical operations 2021-09-17 08:13:54 +01:00
David Hewitt ebada76ae3 pyany: add PyAny::py() 2021-08-13 08:00:13 +01:00
David Hewitt 48823e22d6 pyproto: deprecate py_methods 2021-04-20 00:21:19 +01:00
Askaholic 007bfb7ab0
Refactor py_expect_exception to also verify error string representation 2020-10-13 14:02:14 -08:00
kngwyu 8cbfdd52b8 Simplify test cases where both __*__ and __r*__ are defined 2020-08-20 14:53:47 +09:00
kngwyu 71a7a76227 More tests for RHS 2020-08-20 14:33:47 +09:00
kngwyu f086f48499 Left-hand operands are fellback to RH ones for type mismatching 2020-08-20 14:33:47 +09:00
David Hewitt 1f37dbc1a7 Various fixes to edge cases with GILGuard 2020-08-06 14:32:59 +01:00
Manuel Vázquez Acosta f2ba3e6da7
#1064: Comparisons with __eq__ should not raise TypeError (#1072)
* Add (failing) tests for issue #1064

* Return NotImplemented when richcmp doesn't match the expected type.

* Fix tests that expect TypeError when richcmp returns NotImplemented.

- The python code 'class Other: pass; c2 {} Other()' was raising a NameError:
  c2 not found

- eq and ne never raise a TypeError, so I split the those cases.

* Return NotImplemented for number-like binary operations.

* Add dummy impl PyNumberProtocol for the test struct.

* Rework tests of NotImplemented.

* Make py_ternary_num_func return NotImplemented when type mismatches.

* Return NotImplement for type mismatches in binary inplace operators.

* Reduce boilerplate with `extract_or_return_not_implemented!`

* Extract common definition 'Other' into a function.

* Test explicitly for NotImplemented in the __ipow__ test.

* Add entry in CHANGELOG for PR #1072.

* Add the section 'Emulating numeric types' to the guide.

* Ensure we're returning NotImplemented in tests.

* Simplify the tests: only test we return NotImplemented.

Our previous test were rather indirect: were relying that Python
behaves correctly when we return NotImplemented.

Now we only test that calling a pyclass dunder method returns NotImplemented
when the argument doesn't match the type signature.  This is the expected
behavior.

* Remove reverse operators in tests of NotImplemented

The won't be used because of #844.

* Apply suggestions from code review

Co-authored-by: Yuji Kanagawa <yuji.kngw.80s.revive@gmail.com>

* Add a note about #844 below the list of reflected operations.

Co-authored-by: Yuji Kanagawa <yuji.kngw.80s.revive@gmail.com>
2020-08-05 22:53:16 +09:00
David Hewitt 4ed9748b45 Rename exceptions to PyException etc; reintroduce deprecated ones 2020-07-18 06:02:57 +01:00
David Hewitt a9c7e12be0 Allow skipping the return type completely for `#[pyproto]` methods returning `()`. 2020-06-23 11:51:02 +01:00
kngwyu 69dba08b01 Use PyMethodsImpl instead of *ProtocolImpl::methods 2020-05-11 20:08:21 +09:00
kngwyu 8d1678e28e Separate examples and tooling section in README and the guide 2020-04-02 23:56:19 +09:00
David Hewitt 1efe142566 Fix clippy warning 2020-03-30 11:48:01 +09:00
kngwyu ac418ce020 Inhibit __ipow__ to take Modulo 2020-03-30 03:01:44 +09:00
kngwyu 25eda36353 Speficy METH_COEXIST for some number methods except 2020-03-30 02:02:57 +09:00
kngwyu a76bd7c4e3 Add a test that shows __add__ overrides __radd__ 2020-03-29 00:26:11 +09:00
kngwyu 970e393bb9 Make __r*__ methods work by slot fallback 2020-03-28 18:17:40 +09:00
kngwyu c234476693 chmod -x for test files 2020-03-27 00:41:01 +09:00
kngwyu 02ee7a5afc Expose PyAny to lib.rs and prelude 2020-03-18 13:38:18 +09:00
kngwyu 58590393c5 Fix accidently changed file permission 2019-12-24 12:27:22 +09:00
kngwyu a344999526 [DOC] Add Python from Rust section in the guide 2019-09-23 21:44:42 +09:00
hengchu 149163e059 commenting out one of the rhs arithmetics test case for now... 2019-07-24 16:27:07 -04:00
hengchu 3596cc65c0 adding a small testcase for rhs arithmetics 2019-07-21 23:05:03 -04:00
kngwyu 0f9a3b1194 Expose py_run macro 2019-06-13 18:18:06 +09:00
ijl 2bb0d05a30 Drop support for python2 2019-03-29 12:37:26 +00:00
kngwyu 874d8a0835 Rename PyObjectRef with PyAny 2019-03-04 13:50:43 +09:00
konstin ad590bd158 Some api improvements 2019-02-23 18:01:22 +01:00
konstin 6cb098ee12 Replace py.init_[ref|mut] with Py[Ref|Mut]::new 2019-02-13 21:52:21 +01:00
konstin 1a489d2829 Make the init methods use a value instead of a function 2019-02-13 13:59:47 +01:00
konstin 9e53418aad Less feature(specialization) 2019-02-01 18:09:51 +01:00
konstin 936f0153e8 Migrate to rust 2018 2019-02-01 14:23:29 +01:00
konstin 57afb51604 Remove PyToken completely; Fixes #94 2018-11-12 14:42:21 +01:00
konstin fb2349b6ec Remove PyToken usages from tests 2018-11-12 14:41:29 +01:00
konstin 302c099a76 Big refactoring to shrink the prelude 2018-09-21 23:34:28 +02:00
konstin f58549f1d8 Get rid of a bunch of PyTokens 2018-09-02 23:33:45 +02:00
konstin 991a8b94d2 More nightly fixes 2018-08-19 20:42:17 +02:00
konstin d59bebcc38 Upgrade from proc_macro to use_extern_macros 2018-07-18 13:08:05 +02:00
konstin 4013d40897 Add `py` prefix to the proc macros and move them into the root module
This is important because `proc_macro_path_invoc` isn't going to be stabilized soon.
2018-07-08 23:33:48 +02:00