Commit Graph

973 Commits

Author SHA1 Message Date
Ashley Anderson 5d88e1d1c4
Update PyTryFrom for PyMapping and PySequence to more accurately check types (#2477)
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2022-08-10 21:03:18 +01:00
David Hewitt 78ba70d2b4 pymodule: only allow initializing once per process 2022-08-09 19:52:25 +01:00
mejrs 984fdf57c7 Use Python:;with_gil in tests 2022-07-19 19:34:23 +02:00
David Hewitt d5e99b635d refactor: remove all 0.15 deprecations 2022-07-15 06:33:14 +01:00
David Hewitt 7babd13830 datetime: support timezone bindings 2022-07-13 22:05:17 +01:00
David Hewitt 97ce1f6892 ci: fix nightly UI tests 2022-07-13 08:06:14 +01:00
Ivan Krivosheev 1cd1dbfe8b
Add super object (#2486) 2022-07-03 19:21:15 +01:00
Bruno Kolenbrander 58d4ba833e
Rust 1.62 (#2489)
* Rust 1.62

* Make rust happy

* Just use a doctest instead

Co-authored-by: mejrs <>
2022-07-02 16:08:01 +01:00
David Hewitt 4da9c3a55f llvm-lines: use iterator to collect class items 2022-06-25 22:03:28 +01:00
David Hewitt 62f27caffe ci: fix nightly ui tests 2022-06-25 21:12:14 +01:00
Ashley Anderson bde5102eb8
Increasing test coverage (#2462)
* cov: src/buffer.rs - add tests for debug and element from format

* cov: src/buffer.rs - add some fortran-specific calls in test_array_buffer

* fix issues in MSRV

* cov: src/types/function.rs - directly call PyCFunction::new and PyCFunction::new_with_keywords

* docs: clarify docs of PyCFunction::new and PyCFunction::new_with_keywords

* revert added rust-version for MSRV in Cargo.toml

* cov: src/types/slice.rs - simple tests for PySliceIndices::new

* fix for multi-platform

* Update src/types/function.rs

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

* cov: src/buffer.rs - a better PyBuffer Debug test

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2022-06-23 21:30:22 +01:00
Gabriel Smith 75656949f9 macros: Support #[pyo3(name)] on enum variants 2022-06-22 09:36:40 -04:00
Gabriel Smith 2122faa547 macros: Use macro-defined name for enums in __repr__ 2022-06-21 16:31:23 -04:00
David Hewitt 7725f17c46 pyclass: switch from immutable to frozen 2022-06-19 21:18:15 +01:00
David Hewitt 517f4a87a9
Merge pull request #2450 from mejrs/misc
Fix UB in *_offset functions
2022-06-18 08:53:10 +01:00
David Hewitt f81a01b604 macros: emit pymethod associated methods as a single block 2022-06-16 22:15:29 +01:00
Ivan Krivosheev f19561c745 Allow #[classattr] take Python argument 2022-06-16 13:08:53 +03:00
mejrs 2d3a5852ed Avoid UB in *_offset methods 2022-06-12 15:11:39 +02:00
David Hewitt 7c56a03d64 frompyobject: fix `from_py_with` ignored for transparent structs 2022-06-09 06:49:25 +01:00
Hood Chatham da5b9814cc
Set up CI for wasm32-emscripten target (#2436)
* ci: test on emscripten target

This adds CI to build libpython3.11 for wasm32-emscripten and
running tests against it. We need to patch instant to work
around the emscripten_get_now:
https://github.com/sebcrozet/instant/pull/47

We also have to patch emscripten to work aroung the "undefined
symbol gxx_personality_v0" error:
https://github.com/emscripten-core/emscripten/issues/17128

I set up a nox file to download and install emscripten,
download and build cpython, set appropriate environment variables
then run cargo test. The workflow just installs python, rust,
node, and nox and runs the nox session.

I xfailed all the test failures. There are problems with datetime.
iter_dict_nosegv and test_filenotfounderror should probably be
fixable. The tests that involve threads or asyncio probably can't
be fixed.

* Some cleanup

* Remove instant patch

* Add explanations for xfails
2022-06-08 05:59:18 +01:00
David Hewitt cdf86482d8 ffi: many fixes to pypy definitions 2022-06-04 12:47:40 +01:00
David Hewitt a746411b24
Merge pull request #2422 from davidhewitt/frompyobject-fixes
frompyobject: improve error messages of derived impls
2022-06-02 13:30:03 +01:00
David Hewitt f50406a034
Merge pull request #2413 from davidhewitt/simpler-interned
macros: simpler expansion for `intern!`
2022-06-02 12:54:11 +01:00
David Hewitt 0aa4f95a98 frompyobject: improve error messages of derived impls 2022-06-02 11:13:35 +01:00
David Hewitt 261c0c5f56 macros: simpler expansion for `intern!` 2022-06-02 09:57:58 +01:00
David Hewitt cfb91057af frompyobject: improve error message for tuple case 2022-06-02 08:54:20 +01:00
David Hewitt eafbbc5417
Merge pull request #2399 from davidhewitt/avoid-duplicate-pymethods
pymethods: prevent methods sharing the same name
2022-05-24 22:22:31 +01:00
David Hewitt 879eb14e27
Merge pull request #2395 from davidhewitt/fix-class-raw-ident
macros: fix raw-ident pyclasses having r# at the start of the Python name
2022-05-24 22:08:56 +01:00
David Hewitt 71abeeff8b macros: fix raw-ident pyclasses having r# at the start of the Python name 2022-05-24 21:34:23 +01:00
David Hewitt a306365db8 pymethods: prevent methods sharing the same name 2022-05-24 21:15:30 +01:00
David Hewitt 126bf49b8b
Merge pull request #2377 from herquan/herquan_cr1
Add macro append_to_inittab (issue #2359)
2022-05-24 08:02:47 +01:00
herquan 2ec477344d Add macro append_to_inittab
Sometimes we need to debug in a real environment with our module installed. `append_to_inittab` will be a wrapper for PyImport_AppendInittab (https://docs.python.org/3/c-api/import.html#c.PyImport_AppendInittab) and help us to do this
2022-05-24 07:42:15 +01:00
David Hewitt 0de0e3f8d6 Allow `#[classattr]` methods to be fallible 2022-05-17 21:19:41 +01:00
David Hewitt 8636db67f5 add regression test for PEP 587 2022-05-15 16:08:21 +01:00
Bruno Kolenbrander c57e5098b8
Fix IntoPyCallbackOutput paper cuts (#2326)
* Implement IntoPy for arrays of IntoPy

* Improve `IntoPyCallbackOutput` compile error
2022-05-09 18:15:43 +01:00
Bruno Kolenbrander dce4377eb4
Allow more methods to take interned arguments (#2312)
* Allow more methods to take interned arguments

* Changelog

* Unify name bounds

* Resolve merge conflict

* reduce use of py_decref

* Add some attr tests

* Update migration
2022-05-02 11:13:15 +02:00
David Hewitt 4168feed1b opt: tidy some generic code bloat 2022-04-26 05:36:57 +01:00
cuishuang 19e32a0621 fix some typos
Signed-off-by: cuishuang <imcusg@gmail.com>
2022-04-24 22:06:32 +08:00
David Hewitt 7e2d3117ce cleanup: deprecate PyTypeObject trait 2022-04-23 13:36:32 +01:00
David Hewitt e9bd41efb2 better mutability inheritance rules 2022-04-21 20:51:28 +01:00
mejrs 53a642eda7 Fix ui test 2022-04-12 15:49:23 +02:00
Bruno Kolenbrander bc6bd6099c
Merge branch 'main' into immutable 2022-04-12 14:22:33 +02:00
mejrs b7745dffc8 Fix everything 2022-04-12 14:19:02 +02:00
mejrs 4fc0cdd636 Fix ui test 2022-04-07 23:56:15 +02:00
David Hewitt c16cc35b30 pyclass: mapping flag 2022-04-02 16:15:44 +01:00
mejrs 086424b88c Merge branch 'main' of https://github.com/mejrs/pyo3 into immutable 2022-04-01 23:11:02 +02:00
mejrs 9ab1e6927a Merge branch 'immutable' of https://github.com/mejrs/pyo3 into immutable 2022-04-01 22:59:59 +02:00
Bruno Kolenbrander 43944aef76
Create a better error message for moving self (#2238) 2022-03-24 10:27:37 +01:00
Bruno Kolenbrander fb689340b4
Merge branch 'main' into lint-more 2022-03-23 09:34:31 +01:00
mejrs 6f1cf1b662 Add more lints 2022-03-23 08:07:28 +01:00
David Hewitt 87c79c0319
Merge pull request #2234 from davidhewitt/pyclass-args-refactor
pyclass: unify pyclass with its pyo3 arguments
2022-03-22 11:38:05 +00:00
David Hewitt 5cc3ce99f1 pyclass: unify pyclass with its pyo3 arguments 2022-03-20 08:24:09 +00:00
Alex Gaynor 69655454c1 Added an as_bytes method for Py<PyBytes>
This allows for obtaining a slice that's not lexically bound to the GIL which can be helpful to avoid copying.
2022-03-19 13:28:06 -04:00
David Hewitt ddf13ea98f clippy: enable some more lints 2022-03-03 07:23:28 +00:00
David Hewitt b59ee9b54b misc: tidy ups pre 0.16 2022-02-27 10:02:28 +00:00
Georg Brandl 0678f11266 Protocols: implement __getattribute__
converting tp_getattro to a shared slot

Fixes #2186
2022-02-26 20:05:50 +01:00
Georg Brandl 03dc96bff1
Py/PyAny: remove PartialEq impl and add is() (#2183) 2022-02-25 19:39:45 +00:00
David Hewitt 7c865fcc25
Merge pull request #2173 from davidhewitt/deprecate-pyproto
pyproto: deprecate protocol traits
2022-02-24 23:54:40 +00:00
David Hewitt 424644181b pymethods: add support for inplace concat & repeat 2022-02-24 23:07:24 +00:00
Rico Hageman ed698c4b43 Add documentation related to from_py_with for the FromPyObject trait 2022-02-24 22:54:30 +01:00
Rico Hageman fc186cdb3b Remove item annotation in tuple struct 2022-02-24 22:20:54 +01:00
Rico Hageman 76233e1924 Address pull request comments 2022-02-24 11:27:53 +01:00
Rico Hageman 84a763da14 Add test to ensure support for from_py_with for enums 2022-02-24 00:22:33 +01:00
Rico Hageman 10804b0d65 Support from_py_with on struct tuples 2022-02-24 00:06:33 +01:00
David Hewitt 24445df633 pyproto: deprecate protocol traits 2022-02-23 07:50:52 +00:00
David Hewitt d8ee35e19c
Merge pull request #2165 from mejrs/auto_trait
Implement Auto trait
2022-02-23 07:16:17 +00:00
mejrs ec275d49cb Explicitly (un)implement Ungil 2022-02-22 22:43:40 +01:00
mejrs 10c3e5b094 Try to add nightly feature to CI
Fix stray "
2022-02-22 22:43:40 +01:00
mejrs 9e29c1058c Gut specialization and implement auto trait
Implement auto trait

Implement auto trait

Undo oopsie

Fix versions

Fix CI errors

Fix CI

Remove more specialization remnants
2022-02-22 22:43:23 +01:00
Rico Hageman 3fbdc863cb Include the causes when throwing a PyTypeError when argument parsing failed 2022-02-22 09:48:41 +01:00
Rico Hageman 597e3e17a9 Pass detailed error message to python when parsing an argument fails 2022-02-21 23:22:40 +01:00
David Hewitt 6af47c78f1 pymethods: more tests for magic methods 2022-02-16 07:42:25 +00:00
David Hewitt 79123b396c pyclass: deprecate gc option 2022-02-15 08:01:46 +00:00
David Hewitt 676295b8de pymethods: support gc protocol 2022-02-15 08:01:23 +00:00
David Hewitt c93ee00130 refactor: inline handle_panic into macro output 2022-02-10 20:20:03 +00:00
David Hewitt f5b2a88a70 refactor: include __new__ as slot 2022-02-09 08:07:14 +00:00
David Hewitt 6f39deaa37 finish off implementation 2022-02-08 18:17:44 +00:00
mejrs 7520b49ac1 Implement opt-in immutable pyclasses 2022-02-08 18:08:18 +00:00
b05902132 78f5afc82e Finish implementation for pyclass enums 2022-02-07 22:17:11 +00:00
David Hewitt f75579a489 python-3.11: support buffer API on abi3 2022-02-06 22:46:45 +00:00
David Hewitt ecfd2c2434 pyclass: simplify generated code for PyClassImpl 2022-02-05 16:58:01 +00:00
David Hewitt 558549e1c2 pyproto: split into new feature 2022-02-05 16:51:31 +00:00
David Hewitt 53c170078d pymethods: seq methods from mapping methods 2022-02-05 15:59:22 +00:00
David Hewitt abd7eafafb
Merge pull request #2134 from davidhewitt/optimize-extract-argument
opt: improve generated code for argument extraction
2022-02-05 00:33:45 +00:00
David Hewitt 1beb2bbb2d opt: optimize argument extraction 2022-02-04 20:53:49 +00:00
DSPOM 6a9a9ba38a
move ffi module to separate crate 2022-01-31 13:27:16 +01:00
mejrs 46c458181d Fix more formatting 2022-01-13 23:13:47 +01:00
mejrs f7d7da9b7a Try fix the ci some more 2022-01-13 23:11:33 +01:00
mejrs de175119c1 Formatting 2022-01-13 22:48:36 +01:00
mejrs a8a10ac33d gate the changed errors 2022-01-13 22:43:51 +01:00
mejrs 2006ee0d21 Fix ci 2022-01-13 22:25:23 +01:00
David Hewitt dc8032a5ff pyfunction: allow required positional after option 2022-01-11 00:44:41 +00:00
David Hewitt de8174684f pyfunction: allow wrap_pyfunction to work on imports (even cross-crate) 2022-01-07 08:43:05 +00:00
David Hewitt 2cee7feaaf
Merge pull request #2083 from aviramha/magic_methods
verify py method args count
2022-01-07 00:13:05 +00:00
Aviram Hassan 9ae31f2b87
fix tests 2022-01-06 09:59:10 +02:00
David Hewitt a9b98b7433 pymethods: __ipow__ always receive None on Python 3.7 2022-01-04 22:59:08 +00:00
David Hewitt be70e5441b
Merge pull request #2085 from davidhewitt/opt-argument-extraction
opt: move fastcall boilerplate out of generated code
2022-01-03 08:13:31 +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 1a782ce4db opt: move fastcall boilerplate out of generated code 2022-01-03 00:07:32 +00:00
David Hewitt cf965155f4 pymethods: support buffer protocol 2021-12-30 15:48:55 +00:00
David Hewitt e33b3e6a5b opt: don't emit T::dict_offset and T::weakref_offset without attributes 2021-12-30 14:57:27 +00:00
David Hewitt 807e126178 pyclass: no need to try inherit base dict and weaklist 2021-12-30 14:17:58 +00:00
David Hewitt ff37f24625 macros: accept paths in wrap_x macros 2021-12-30 12:46:57 +00:00
David Hewitt 5be5d77589 opt: improve handle_panic generated code 2021-12-24 00:17:04 +00:00
David Hewitt 492b7e4c0f macros: optimize generated code for #[derive(FromPyObject)] 2021-12-22 08:34:05 +00:00
David Hewitt 5cab5d4da3 misc: remove some more *const -> *mut pointer casts 2021-12-20 20:36:46 +00:00
David Hewitt 469d72a001
Merge pull request #2022 from PyO3/pyo3_path
Hygiene: offer a way to set path to pyo3 crate
2021-12-09 20:27:48 +00:00
Juniper Parsons 47cf13239f
Disallow positional args after optional args 2021-12-09 10:01:59 -05:00
Georg Brandl a5b76bc365 pyo3_path, part 4: rename to `crate` to keep consistent with serde 2021-12-09 07:36:48 +01:00
Georg Brandl 681217d8d9 pyo3_path, part 3: move test_hygiene into lib crate
This removes the crate-root `pyo3` item to ensure that our
selected pyo3_path needs to be taken into account.
2021-12-09 07:36:48 +01:00
Georg Brandl e4f608f605 pyo3_path, part 2: add pyo3_path options and use them. 2021-12-09 07:24:18 +01:00
David Hewitt 6433d884fc dev: remove self dev dependency 2021-12-08 07:48:58 +00:00
David Hewitt 4c8abd1426 rust: support 1.57 2021-12-08 07:10:16 +00:00
b05902132 aac0e566b0 Allow default implementation of slots. Add default __repr__ for enums. 2021-11-29 17:35:18 +08:00
Georg Brandl 9990bf9d31 Fix some clippy and dead code warnings. 2021-11-24 09:11:39 +01:00
b05902132 d339cd0dc9 Let #[pyclass] reject empty enums. 2021-11-23 01:15:07 +08:00
mejrs a44e2f8eea Fix formatting. 2021-11-22 10:19:46 +01:00
Bruno Kolenbrander 3bf9ef0706
Merge branch 'main' into immutable 2021-11-22 10:08:51 +01:00
mejrs 0fa03a67cd Implement opt-in immutable pyclasses 2021-11-22 09:26:34 +01:00
b05902132 b7419b5278 Refactor #[pyclass] and now it supports enum.
There's no functionality since it does not generate __richcmp__.

Also it only works on enums with only variants, and does not support
C-like enums.
2021-11-21 20:05:53 +08:00
David Hewitt e9b46f76da
Merge pull request #1985 from PyO3/is_instance_of
add PyType::is_subclass_of and PyAny::is_instance_of
2021-11-20 14:56:36 +00:00
David Hewitt ded44eebfb
Merge pull request #2006 from davidhewitt/drop-py36
python: drop support for 3.6
2021-11-20 14:04:31 +00:00
mejrs a28be4d9bf Revert "Implement by default immutable pyclasses"
This reverts commit 7f31000be2.
2021-11-20 14:58:56 +01:00
Georg Brandl 43893158b1 switch is_instance/is_instance_of, is_subclass/is_subclass_of 2021-11-20 13:18:43 +00:00
Georg Brandl a83c31a3af add PyType::is_subclass_of and PyAny::is_instance_of
which get the type to check against as an arguments,
as opposed to a compile-time generic type.
2021-11-20 13:16:15 +00:00
David Hewitt 70030f130d python: drop support for 3.6 2021-11-20 13:02:42 +00:00
David Hewitt c9a4cd1f87 deprecations: remove items deprecated in PyO3 0.14 2021-11-19 16:33:29 +00:00
David Hewitt 6a65f98bd2 msrv: bump to 1.48 2021-11-19 10:10:59 +00:00
David Hewitt 26ccc1ab37 macros: fix panic in __get__ implementation 2021-11-15 16:02:59 +00:00
David Hewitt 23778f5386 pymethods: test and document opt-out of protos 2021-11-10 23:28:01 +00:00
mejrs 7f31000be2 Implement by default immutable pyclasses 2021-11-10 15:28:19 +01:00
Bruno Kolenbrander 7b9ae8e663
Clean up `Python` documentation (#1963)
* Clean up `Python` documentation

* Apply suggestion

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

* Fix some things

* Fix PyPy link

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2021-11-02 23:05:44 +00:00
David Hewitt 3ab32ff01f guide: magic methods in pymethods 2021-10-24 15:59:22 +01:00
David Hewitt 0236879e8e pymethods: test __delete__ 2021-10-24 09:40:32 +01:00
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
David Hewitt 54ddd5aad7 tests: move ui tests updated for rust 1.56 to new section 2021-10-22 23:16:39 +01:00
messense d6401966f9 Update UI tests output 2021-10-22 16:40:57 +08: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 5a1660f7c8
Merge pull request #1924 from davidhewitt/rtruediv-rfloordiv
pymethods: support __rtruediv__ and __rfloordiv__
2021-10-17 10:00:11 +01:00
David Hewitt 212404bc23 pymethods: support __rtruediv__ and __rfloordiv__ 2021-10-17 08:33:46 +01:00
laurent 2042906832 pycfunction: add PyCFunction::new_closure rust defined closures 2021-10-17 07:59:50 +01:00
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
messense b5b9a480cd Add `wrap_pyfunction` macro to prelude 2021-06-24 22:34:55 +08:00
Giles Cope 08802e2024 property rename via macro 2021-06-24 09:06:47 +01:00
Giles Cope 2688e26391 Bit more coverage 2021-06-24 08:59:35 +01:00
Giles Cope aaad7ffd63 Need to be able to create structs via macro_rules
(Currently only possible using tt escape type.)
2021-06-24 08:40:49 +01:00
David Hewitt f916867375 pyclass: refactor initialization, call native type dealloc 2021-06-23 07:45:51 +01:00
mejrs 445f5163d4 update error message for rust 1.53 2021-06-19 16:11:03 +02:00
R2D2 d3208b005e Removed stray newline character from error message 2021-06-09 14:25:49 +02:00
R2D2 ec40446fa3 Removed stray newline character from error message 2021-06-09 14:23:16 +02:00
R2D2 e6da1ebc73 Fixed formatting of error messages and tests 2021-06-09 11:40:14 +02:00
R2D2 0b3fbb5533 Fixed formatting 2021-06-07 10:26:58 +02:00
R2D2 973f0a5bae Removed the custom error messages from the macro api 2021-06-07 10:18:38 +02:00
David Hewitt 18e0aa17e0 pymodule: accept `#[pyo3(name = "...")]` option 2021-06-06 08:41:20 +01:00
David Hewitt 9b8b133905 pyfunction: document `#[pyo3(pass_module)]` 2021-06-05 17:36:50 +01:00
David Hewitt cec4c2d2e9 text_signature: move to `#[pyo3(text_signature = "...")]` 2021-06-05 16:33:03 +01:00
Georg Brandl 3e8d003faf Implement METH_FASTCALL for pyfunctions and pymethods. 2021-06-05 12:57:22 +02:00
David Hewitt d011467e63 pyclass: allow `#[pyo3(get, set, name = "foo")]` 2021-06-04 11:30:40 +01:00
R2D2 416b1132b4 Added custom error messages to enum fields and container types. Covered with tests. Fixed formatting and linting issues 2021-06-01 22:44:16 +02:00
R2D2 dfc484c43b Started adding more unit tests 2021-06-01 00:23:54 +02:00
R2D2 1a8fec2e88 Added detailed TypeError messages to enums with derive(FromPyOjbect) 2021-05-31 17:38:15 +02:00
R2D2 4a99bfaaba Fixed tests after modifying TypeErrors originating from structs. Started work on TypeError message on Enums 2021-05-31 00:28:53 +02:00
David Hewitt 9f74336bc9 pyfunction: better error message with `async fn` 2021-05-25 11:32:52 +01:00
David Hewitt cfdd535eea
Merge pull request #1610 from davidhewitt/pyfn-name
pyfn: deprecate name argument
2021-05-23 23:08:43 +01:00
David Hewitt a109640850 pyfn: deprecate name argument 2021-05-20 08:54:29 +01:00
Georg Brandl 4539e3524b Fix new-in-nightly clippy warning
Example:

error: used `assert_eq!` with a literal bool
   --> src/types/sequence.rs:675:9
    |
675 |         assert_eq!(empty_seq.is_empty().unwrap(), true);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `assert!(..)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_assert_comparison
2021-05-17 09:59:40 +02:00
David Hewitt 4d46abde73 macros: support `#[pyo3(name = "...")]` 2021-05-07 22:35:52 +01:00
David Hewitt 4613b3dd7e
Merge pull request #1596 from davidhewitt/remove-pytypeinfo-layout
type_object: remove layout and base type from PyTypeInfo
2021-05-07 22:32:24 +01:00
messense 272d014518
Merge pull request #1598 from davidhewitt/rust-1.52
rust: updates for rust 1.52
2021-05-07 09:01:38 +08:00
David Hewitt defd09c166 rust: updates for rust 1.52 2021-05-06 23:18:34 +01:00
Mara Bos d33c5010c7 Add test for wrap_pyfunction!() deduction. 2021-05-06 16:05:17 +02:00
David Hewitt d81abe8344 pyclass: support extending Exception types 2021-05-04 22:00:22 +01:00
David Hewitt 7536554ceb type_object: remove layout and base type from PyTypeInfo 2021-05-04 21:39:42 +01:00
David Hewitt 48823e22d6 pyproto: deprecate py_methods 2021-04-20 00:21:19 +01:00
David Hewitt 9cdec14454
Merge pull request #1559 from davidhewitt/tidy-clippy-allows
clippy: tidy up allow lints
2021-04-12 19:02:04 +01:00
David Hewitt aa0b5d8488 buffer: tidy up exceptions 2021-04-12 01:21:48 +01:00
David Hewitt ac0bd0c0f1 clippy: tidy up allow lints 2021-04-12 01:20:04 +01:00
David Hewitt ce851ad7d9 1506: fixes to macro hygiene 2021-03-28 11:01:51 +01:00
messense 90c5ffbd04 Fix clippy warnings in Rust 1.51.0 2021-03-26 13:21:38 +08:00
David Hewitt 246335bee2
Merge pull request #1505 from scalexm/macro
Ignore `syn::Type::Group` in `is_python`
2021-03-20 11:09:04 +00:00
David Hewitt e34e87ad4a 1505: add CHANGELOG and test 2021-03-20 08:36:19 +00:00
Yuji Kanagawa f0763f069e
Merge pull request #1507 from scalexm/getter-name
Allow `#[name]` with `#[getter]` and `#[setter]`
2021-03-20 16:23:07 +09:00
Yuji Kanagawa acff3b1f3e
Merge pull request #1504 from PyO3/pyclass
Add tuple and unit struct support for pyclass macro
2021-03-20 16:14:15 +09:00
messense acd4601d2f Remove __doc__ from module's __all__ 2021-03-20 11:25:36 +08:00
messense 1c57294214 Use Python::with_gil and py_assert
Co-authored-by: Yuji Kanagawa <yuji.kngw.80s.revive@gmail.com>
2021-03-19 10:17:06 +08:00
messense 2cec240b0e Ban pyo3(get, set) on tuple struct field 2021-03-19 10:17:06 +08:00
messense 773a371ba5 Add tuple and unit struct support for pyclass macro 2021-03-19 10:17:06 +08:00
scalexm b27ee3fd64 Allow `#[name]` with `#[getter]` and `#[setter]` 2021-03-18 19:35:17 +01:00
Yuji Kanagawa acf7271879
Merge pull request #1494 from PyO3/enhance-py-run
Extend py_run! to take locals dict and refactor tests using it
2021-03-17 12:52:33 +09:00
kngwyu 9b88a452e2 Refactor tests to use shorter macros 2021-03-14 23:43:53 +09:00
David Hewitt b10cefdca2 pymodule: remove call_function etc. 2021-03-14 11:19:55 +00:00
kngwyu 7ec1fed798 Extend py_run! macro to take dict as *d syntax 2021-03-14 16:33:49 +09:00
David Hewitt 66b3022d0e
Merge pull request #1483 from davidhewitt/macros-tidy-ups
pymethods: macros tidy-ups
2021-03-14 00:09:23 +00:00
David Hewitt 9613228a0c pyfunction: reject generic functions 2021-03-09 23:47:47 +00:00
David Hewitt 78080ebbd2 macros-backend: support noargs for pyproto py_methods 2021-03-08 23:56:08 +00:00
David Hewitt d75d109aee
Merge pull request #1472 from davidhewitt/nightly-warnings
ci: fix nightly warnings
2021-03-06 23:10:48 +00:00
David Hewitt e19c083a81 ci: fix nightly warnings 2021-03-06 09:42:50 +00:00
David Hewitt 977735db20 pymethods: make inventory optional 2021-03-04 19:52:58 +00:00
Yuji Kanagawa 21b26fcf3a
Merge pull request #1440 from davidhewitt/fix-multiple-kw-only-arg
pyfunction: refactor argument extraction
2021-03-04 00:15:34 +09:00