Commit Graph

3786 Commits

Author SHA1 Message Date
David Hewitt be239d405f Rework Py methods and documentation 2020-08-09 12:29:25 +01:00
David Hewitt 20959ecc92 Rewrite documentation for FromPy and PyObject changes 2020-08-09 12:29:25 +01:00
David Hewitt f29e6bae7a Replace PyObject with type alias for Py<T> 2020-08-09 12:28:21 +01:00
David Hewitt 7901890974 Remove `FromPy` 2020-08-09 12:28:21 +01:00
David Hewitt 206bf96b11
Merge pull request #1086 from davidhewitt/contributing
Make contributing notes much more helpful
2020-08-09 12:16:38 +01:00
David Hewitt 7fe989693c Move fmt and clippy to actions 2020-08-09 12:15:54 +01:00
Yuji Kanagawa ff9cde46e1
Merge pull request #1097 from kngwyu/refactor-buildrs
Refactor build.rs
2020-08-09 18:31:19 +09:00
kngwyu 5ae8639cc8 Refactor build.rs 2020-08-09 18:07:14 +09:00
Yuji Kanagawa b71018689d
Merge pull request #1096 from davidhewitt/docs-rs
Prefer docs.rs doc links
2020-08-09 16:47:27 +09:00
David Hewitt c44697cd31 Prefer docs.rs doc links 2020-08-08 23:54:11 +01:00
David Hewitt 7e4995f860 Simplify language in Contributing.md 2020-08-08 23:41:31 +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 801d955a9c
Merge pull request #1092 from davidhewitt/pypy36
Experimental support for PyPy 3.6
2020-08-08 15:38:27 +01:00
David Hewitt e0376d24aa Experimental support for PyPy 3.6
Co-authored-by: Yuji Kanagawa <yuji.kngw.80s.revive@gmail.com>
2020-08-08 14:54:34 +01:00
Yuji Kanagawa c66bc540c8
Merge pull request #1091 from davidhewitt/remove-redundant-test
Remove redundant iter test
2020-08-08 16:06:04 +09:00
David Hewitt e72b682038 Remove redundant iter test 2020-08-07 13:49:52 +01:00
David Hewitt 3809e2b3e9
Merge pull request #1087 from davidhewitt/tidy-link
Only use `#[link]` for static mut
2020-08-07 09:08:21 +01:00
David Hewitt 616067230a Only use `#[link]` for static mut 2020-08-07 06:21:39 +01:00
David Hewitt 9c212035ef Make contributing notes much more helpful 2020-08-06 18:39:32 +01:00
David Hewitt 9823019c90
Merge pull request #1036 from davidhewitt/fix-gilguard
Various fixes to edge cases with GILGuard
2020-08-06 15:36:14 +01:00
Moritz Langenstein 4b3422e3b4 Simplified fallible PyBytes::new_with and PyByteArray::new_with API 2020-08-06 14:08:43 +00:00
David Hewitt 1f37dbc1a7 Various fixes to edge cases with GILGuard 2020-08-06 14:32:59 +01:00
David Hewitt 11b6bacc4d
Merge pull request #1039 from davidhewitt/pyo3-interpreter
Rename PYTHON_SYS_EXECUTABLE to PYO3_PYTHON
2020-08-06 14:26:07 +01:00
David Hewitt dc5c2a9b8f Rename PYTHON_SYS_EXECUTABLE to PYO3_PYTHON 2020-08-06 13:27:20 +01:00
Moritz Langenstein aeceb18603 Changed PyByte::new_init and PyByteArray::new_init such that init can fail 2020-08-06 08:48:06 +00: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
Yuji Kanagawa 3ac327c8e0
Merge pull request #1080 from Hakuyume/use-qualified-path-in-derive
Use qualified path in derive
2020-08-04 21:01:48 +09:00
Toru Ogawa 668e5e9d1f PyObject -> pyo3::PyObject 2020-08-04 20:27:29 +09:00
Moritz Langenstein a877300f72
Added Rust initialisation of Python-allocated bytes (#1074)
* Added Rust initialisation of Python-allocated bytes

* Added unsafe PyBytes::new_with_unit constructor

* Added examples to PyBytes::new_with and PyBytes::new_with_uninit (now with MaybeUninit<u8>)

* Fixed doc test imports for PyBytes::new_with and PyBytes::new_with_uninit

* Fixed clippy error in PyBytes::new_with_uninit test

* Added PyByteArray::new_with and Removed PyBytes::new_with_uninit

* Small doc fixes + FnOnce init closure for PyBytes::new_with and PyByteArray::new_with

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>

* Fixed where clause formatting in PyBytes::new_with and PyByteArray::new_with

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2020-08-03 09:04:06 +01:00
David Hewitt 80224207cc
Merge pull request #1075 from davidhewitt/update-pr-template
Update PR template
2020-08-02 13:41:21 +01:00
Yuji Kanagawa aaeb5eab54
Merge pull request #1067 from davidhewitt/pyerr-send
Make `PyErr: Send + Sync`
2020-08-02 17:49:11 +09:00
David Hewitt 7b36f3a44b Apply suggestions from kngwyu
Co-authored-by: Yuji Kanagawa <yuji.kngw.80s.revive@gmail.com>
2020-08-02 02:08:47 +01:00
David Hewitt 52f7429748 Update PR template 2020-08-02 01:09:52 +01:00
Yuji Kanagawa 51171f7475
Merge pull request #1071 from kngwyu/ref-self-regression
Enable &Self in #[pymethods] again
2020-07-29 00:30:38 +09:00
kngwyu f5f2e84f4b Enable &Self in #[pymethods] again 2020-07-28 20:55:38 +09:00
David Hewitt 09aef5d299 Make `PyErr: Send + Sync` 2020-07-25 11:59:44 +01:00
Yuji Kanagawa b05eb4814b
Merge pull request #1060 from sebpuetz/memoffset
Calculate offsets for weakreflist and dict in PyCell.
2020-07-21 18:53:29 +09:00
Yuji Kanagawa 4563e00a67 Add testcase for unsendable, dict, weakref pyclass. 2020-07-21 10:42:36 +02:00
Sebastian Puetz 43d1f43c72 Calculate offsets for weakreflist and dict in PyCell. 2020-07-21 10:38:20 +02:00
David Hewitt 4cf0db0476
Merge pull request #1058 from sebpuetz/dict-unsendable
Move the ThreadChecker field in front of dict and weakref.
2020-07-20 19:21:30 +01: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
Yuji Kanagawa be67a152ce
Merge pull request #1054 from davidhewitt/cleanup-pyerr-hidden-apis
Remove hidden PyErr::restore_and_minus1 and PyErr::restore_and_null
2020-07-20 12:29:27 +09:00
David Hewitt a97e641622
Merge pull request #1052 from vorner/pyo3-docs
docs: Link to pyo3-log in README and the guide
2020-07-19 23:24:54 +01:00
David Hewitt 0764362d17 Remove hidden PyErr::restore_and_minus1 and PyErr::restore_and_null 2020-07-19 22:39:41 +01:00
Michal 'vorner' Vaner e6dd2d980f
docs: Link to pyo3-log in README and the guide
Show how one can log from Rust through the Python's logging facilities.

Related to #1016.
2020-07-19 22:01:22 +02:00
David Hewitt 25053599b7
Merge pull request #1053 from sebpuetz/conversion-matches
Remove explicit matches in conversions.
2020-07-19 13:25:21 +01:00
Sebastian Puetz 77d03d01f3 Remove explicit matches in conversions.
Don't explicitly match Options and Results if only one of the
variants is changed.
2020-07-19 13:26:59 +02:00
David Hewitt 53a248c617
Merge pull request #1050 from sebpuetz/conversion-errors
Add type info to conversion errors.
2020-07-19 12:01:31 +01:00
David Hewitt a058eb5201
Remove redundant lifetimes 2020-07-19 11:23:07 +01:00