Commit Graph

452 Commits

Author SHA1 Message Date
David Hewitt 565e36d989
Merge pull request #1098 from davidhewitt/py-as-into-ref
Py::as_ref and Py::into_ref (remove AsPyRef)
2020-08-11 20:44:53 +01:00
Yuji Kanagawa c4d9ab227e
Merge branch 'master' into iterator-example 2020-08-10 17:11:00 +09:00
kngwyu 093dda375f Improve lifetime insertions for #[pyproto] 2020-08-10 15:18:16 +09:00
David Hewitt 77ed6d6d69 Remove AsPyRef for just Py::as_ref 2020-08-09 22:47:54 +01:00
David Hewitt ffd6e562ab
Merge pull request #1090 from davidhewitt/unsendable-test-tidy
Change unsendable test to use Rust thread
2020-08-08 18:21:38 +01:00
David Hewitt ad76a8a5ce Change unsendable test to use Rust thread 2020-08-08 17:45:41 +01:00
David Hewitt e72b682038 Remove redundant iter test 2020-08-07 13:49:52 +01: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
kngwyu f5f2e84f4b Enable &Self in #[pymethods] again 2020-07-28 20:55:38 +09:00
Yuji Kanagawa 4563e00a67 Add testcase for unsendable, dict, weakref pyclass. 2020-07-21 10:42:36 +02:00
Sebastian Puetz e75f768ea8 Move the ThreadChecker field in front of dict and weakref.
Offsets for dict and weakref are calculated from the end of the
PyCell struct. When using the non-dummy ThreadChecker, the offsets
were invalid since the `ThreadCheckerImpl` is not zero-sized.
2020-07-20 19:37:38 +02:00
David Hewitt 4ed9748b45 Rename exceptions to PyException etc; reintroduce deprecated ones 2020-07-18 06:02:57 +01:00
David Hewitt a7e0c6bfa7 Make exceptions proper native types. 2020-07-18 01:57:39 +01:00
kngwyu 3ae1caa55a Skip panic_unsendable test if -Cpanic=abort is given 2020-06-30 17:58:31 +09:00
kngwyu d76fe7835a Introduce #[pyclass(unsendable)] 2020-06-30 12:30:17 +09:00
David Hewitt c3e993e5a6 Apply suggestions from code review
Co-authored-by: Yuji Kanagawa <yuji.kngw.80s.revive@gmail.com>
2020-06-27 14:56:15 +01:00
David Hewitt e140b729fc Allow #[getter] and #[setter] functions to take PyRef 2020-06-27 14:55:22 +01:00
kngwyu a78a832431 Refactor around the nightly feature 2020-06-26 19:29:37 +09:00
scalexm f49478619f Re-enable recursive class attributes
Use some kind of two-stage initialization as described in #975, by
being very cautious about when to allow the GIL to be released.
2020-06-23 22:40:29 +02:00
David Hewitt a9c7e12be0 Allow skipping the return type completely for `#[pyproto]` methods returning `()`. 2020-06-23 11:51:02 +01:00
David Hewitt c7a4b4770f Refactor `#[pyproto]` Result types 2020-06-23 11:08:36 +01:00
kngwyu b70ee9a5ad Use subclass correctly in tp_new 2020-06-22 01:38:13 +09:00
Yuji Kanagawa 7075827a03
Merge pull request #969 from PyO3/poc-stable-rust
Stable Rust
2020-06-21 16:54:59 +09:00
kngwyu a63e426f6f Some doc and test cleanups mainly around specialization 2020-06-20 12:59:56 +09:00
David Hewitt a1dbfa8c8c Add pyo3::once_cell::GILOnceCell 2020-06-18 18:53:32 +01:00
kngwyu a840ebbb5a Support Rust 1.39.0 2020-06-18 19:59:40 +09:00
kngwyu 654ab4c819 Enable tests for --features nighly on travis 2020-06-18 18:16:01 +09:00
kngwyu 0f709d6edc Use paste instead of nightly concat_idents in datetime tests 2020-06-18 18:15:36 +09:00
konstin 6798fe9da7 Fix tests on stable 2020-06-18 17:23:49 +09:00
konstin 3180e5cc06 POC stable rust (2 tests failing) 2020-06-18 17:21:09 +09:00
Yuji Kanagawa a044f3c322
Merge branch 'master' into slot-provider 2020-06-18 15:49:56 +09:00
kngwyu 1207c2d03a Make test_await more robust 2020-06-18 01:58:01 +09:00
kngwyu 2e1ed2c3c8 Descr get/set now take receiver 2020-06-15 13:43:46 +09:00
David Hewitt a85d157111 Cleanups to ensure GIL-safety of Py<T> and PyObject methods 2020-06-14 16:37:34 +01:00
kngwyu 8c4162dfeb Async methods now takes Receiver 2020-06-14 22:43:07 +09:00
kngwyu f32277163a Move nb_bool under PyObjectProtocol again 2020-06-13 15:25:04 +09:00
kngwyu 7967874177 Remove specialization from basic/buffer/descr/iter protocols 2020-06-13 15:24:56 +09:00
David 33617bfffc Require Send for #[pyclass] 2020-06-08 02:06:15 +01:00
Yuji Kanagawa d674b5ff34
Merge pull request #952 from kngwyu/typed-pybuffer
Typed PyBuffer
2020-06-05 23:08:07 +09:00
Alexander Niederbühl bcf48c0bd2 Fix clippy lints 2020-06-05 13:53:01 +02:00
Yuji Kanagawa 5939362e72
Fix docs and comments based on the review
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2020-06-05 17:48:43 +09:00
kngwyu 688021315e Typed PyBuffer 2020-06-04 22:03:53 +09:00
David Hewitt 29c93c87c7 Remove GetPropertyValue 2020-05-21 18:06:24 +01:00
Yuji Kanagawa 7fd35b2fb6
Merge pull request #937 from davidhewitt/doc-conversion-table
Add conversion table to guide
2020-05-21 16:18:46 +09:00
David Hewitt 2813d2e6c9 Add conversion table to guide 2020-05-19 22:22:38 +01:00
David Hewitt 5c5527dfec Fix passing explicit None to pyfunction with default 2020-05-17 19:19:33 +01:00
kngwyu 69dba08b01 Use PyMethodsImpl instead of *ProtocolImpl::methods 2020-05-11 20:08:21 +09:00
scalexm f6ac9a0212 Allow `#[classattr]` on associated constants 2020-05-08 22:30:49 +02:00
Yuji Kanagawa d5eb8f0544
Merge pull request #911 from davidhewitt/remove-objectprotocol
Remove ObjectProtocol
2020-05-08 18:56:52 +09:00