Commit Graph

152 Commits

Author SHA1 Message Date
David Hewitt 0e0e6f8bf5 pymethods: support protocols with `multiple-pymethods` feature 2021-10-23 00:07:35 +01:00
David Hewitt 4b2345fe80 pymethods: support __call__ proto 2021-10-23 00:06:46 +01:00
Azat Ibrakov 7349513f5b
Add fallback for `__mod__` magic method (#1934)
* Add fallback for `__mod__` magic method

* Add 'CHANGELOG' entry

* Complete tests
2021-10-19 23:14:26 +01:00
Ashley Anderson bf26daec2d
Positional-only args (#1925)
* Add support for positional-only args

* Update changelog. Add a few more tests. Run rust-fmt.

* Fix test.

* Fix tests again.

* Update CHANGELOG.md to link PR instead of issue

* Update guide to mention positional-only params

* Add unreachable!() per code review

* Update and expand tests for pos args.

* Fix tests, lint, add UI tests.

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2021-10-19 23:13:27 +01:00
David Hewitt 212404bc23 pymethods: support __rtruediv__ and __rfloordiv__ 2021-10-17 08:33:46 +01:00
Bruno Kolenbrander 8a57fe2d20
Clean up doctests, deny some lints (#1900)
* Clean up doctests, deny some lints

* Apply suggestions from review.

* replace \" with '

* Fix some more doc examples

* Fix formatting

* Fix some more things

* Remove unused parentheses

* Only test class sig on supported abi/platforms

* Only test class signature on correct versions

* Fix tests to compile on msrv

* msrv strikes yet again

* Add feedback

* Pin `half` to 1.7.1 on msrv
2021-10-14 22:15:25 +01:00
mejrs ed991d23a3 Fix ambiguous imports 2021-10-02 19:00:51 +02:00
Mo Mirza 4a34cc63a6
Remove use of unwrap (#1888)
* Remove use of unwrap

* Update changelog

* Update CHANGELOG.md

Co-authored-by: Mo Mirza <mo.mirza@iwoca.co.uk>
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2021-09-26 09:01:23 +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 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 92e2156161 pymethods: support inplace numerical operations 2021-09-17 08:13:54 +01:00
David Hewitt c090b6581d pymethods: fix clippy errors 2021-09-17 08:13:54 +01:00
David Hewitt 5210517695 pymethods: implement more mapping methods 2021-09-17 08:13:54 +01:00
David Hewitt fda18b07d7 pymethods: implement some mapping methods 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
David Hewitt dca02a92ce changelog: updates for 0.14.5 backports 2021-09-05 15:19:36 +01:00
Gregory Szorc 1e951d5d8b pyo3-build-config: add a crate feature to control build script
I have a use case in PyOxidizer where I want to use the
pyo3-build-config crate as a library crate so I can access the
`InterpreterConfig` struct so I can read/write config files without
reinventing the wheel.

This is doable before this commit. But it requires that the
build environment have a Python interpreter. This is undesirable
for library usage.

This commit introduces a cargo feature flag to control whether the
build script does anything. The feature flag must be present for
the build script to resolve a config. The feature flag is enabled
by default for backwards compatibility. The pyo3 and pyo3-macros-backend
crates use this feature by default, for backwards compatibility and
because it is the reasonable default.

This is probably room to conditionalize some APIs and other behavior
based on this feature flag. But we stop short of doing that for
the time being.
2021-09-01 19:44:54 -07:00
David Hewitt b7c62b8a53
Merge pull request #1846 from davidhewitt/changelog-release-0.14.4
changelog: updates for 0.14.4
2021-08-30 08:19:53 +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
David Hewitt 5119bad580 changelog: updates for 0.14.4 2021-08-29 08:07:44 +01: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 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
David Hewitt 313610993a pyo3-macros-backend: more tests for macro hygiene 2021-08-28 10:28:27 +01:00
David Hewitt bc1a983371 changelog: update for 0.14.3 release 2021-08-22 01:25:29 +01: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 21196e68e2 fully disambiguate types 2021-08-17 22:32:41 +02:00
Aviram Hassan c6255e6734 - `PyList`, `PyTuple` and `PySequence`'s `get_item` now accepts only `usize` indices instead of `isize`.
- `PyList` and `PyTuple`'s `get_item` now always uses the safe API. See `get_item_unchecked` for retrieving index without checks.
2021-08-17 15:01:22 +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 1873264b7d release: 0.14.2 2021-08-09 07:58:31 +01:00
Dean Li 1086fdb965
fix compiler warning
Fix issue [link](https://github.com/rust-lang/rust/issues/79813) which
will eventually deny trailing semicolons in expression macro in rust compiler.
2021-08-07 16:31:54 +08: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 5b8efdd6e2 Refactored to prevent re-acquiring the gil 2021-08-01 22:38:34 +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
R2D2 a42447bfe2 Small refactor 2021-07-31 21:20:57 +02:00
Jacob Turner 363383ea84
Update pyo3-macros-backend/src/from_pyobject.rs
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2021-07-31 20:38:44 +02:00
David Hewitt ee9a1678d5 rust: updates for rust & clippy 1.54 2021-07-31 08:19:38 +01:00
David Hewitt a7244b864d testing: use `mod tests` instead of `mod test` 2021-07-26 18:19:53 +01:00
Alex Gaynor 82697bfec0
workaround an issue that causes function arguments to show up as if they are uncovered
https://github.com/rust-lang/rust/issues/86972 describes this issue in some detail and links to a minimal reproducer

making this change, and this change alone, resolves the coverage issues
2021-07-14 23:38:08 -04:00
David Hewitt d11943ab6d macros-backend: don't error on #[doc(hidden)] 2021-07-08 23:41:24 +01:00
David Hewitt 3f8c4ad38e release: 0.14.1 2021-07-04 16:49:36 +01:00
David Hewitt adf6bdba8e release: 0.14.0 2021-07-03 08:37:00 +01:00