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
David Hewitt
29a525b327
pyfunction: refactor argument extraction
2021-03-01 17:49:46 +00:00
David Hewitt
ffd5874c3a
pyfunction: fix args conflicting with keyword only arg
2021-03-01 17:49:46 +00:00
konstin
f97c3a9479
Convert callback_body_without_convert function to handle_panic function
2021-03-01 12:42:19 +01:00
Daniil Konovalenko
554cffd60d
add #[pyo3(from_py_with="...")] attribute ( #1411 )
...
* allow from_py_with inside #[derive(FromPyObject)]
* split up FnSpec::parse
2021-02-21 00:15:20 +09:00
David Hewitt
7b99e391fa
pyclass-impl: merge implementation traits
2021-02-18 08:19:07 +00:00
David Hewitt
b2675b11fe
rust 1.50: clippy and lint fixes
2021-02-11 22:03:34 +00:00
Georg Brandl
fa8d7518ca
Restore compatibility with Rust 1.41.
...
This version is currently supported by Debian stable and Alpine Linux.
Fixes #1420
2021-02-11 10:14:25 +01:00
David Hewitt
9807ef8ed4
macros-backend: fix raw idents in pymethods
2021-01-12 22:01:11 +00:00
David Hewitt
0729fb1e03
Merge pull request #1374 from davidhewitt/macros-error-handling
...
macros-backend: improve error handling ergonomics
2021-01-12 08:05:30 +00:00
Daniil Konovalenko
abb5829e9c
implement Serialize, Deserialize for Py<T>
2021-01-11 22:19:10 +00:00
David Hewitt
88872eba4f
macros-backend: improve error handling ergonomics
2021-01-10 10:25:43 +00:00
David Hewitt
b92441cd7c
pyclass: fix reference count issue in subclass new
2021-01-08 00:13:49 +00:00
David Hewitt
22de3b4f44
pyclass: add !Send compile_error test
2021-01-05 23:25:28 +00:00
David Hewitt
b1012ebb68
build: update for Rust 1.49
2020-12-31 18:16:02 +00:00
David Hewitt
7572962828
abi3: add support for dict and weakref from Python 3.9
2020-12-28 10:22:46 +00:00
David Hewitt
db74cc85fa
pypy: final fix
2020-12-20 13:50:39 +00:00
kngwyu
dc2dbd6c19
Use #[cfg(not(Py_LIMITED_API))] for datetime API
2020-12-20 12:20:35 +00:00
David Hewitt
fa8c93cfd1
pyclass #[new]: allow using custom error type
2020-12-13 23:50:03 +00:00
David Hewitt
5133f81e6d
deprecate pyclass name without quotes
2020-12-12 11:11:11 +00:00
scalexm
7dadf59fde
Do not include the double quotes in `#[pyclass(name = "literal")]`
2020-11-30 22:04:07 +01:00
scalexm
649b439463
Allow `#[pyclass(name = "string literal")]`
...
This is also more in line with the `#[name = "..."]` attribute on
methods.
2020-11-27 18:45:07 +01:00
roblabla
d479b54b94
Fix #1285 , text_signature and raw ident interaction
2020-11-19 17:21:02 +00:00
David Hewitt
8a8c098a2e
rust-1.48: fix tests and warnings
2020-11-19 12:49:29 +00:00
David Hewitt
45599620b5
pyerr: improve debug & display impls
2020-11-15 16:22:45 +00:00
David Hewitt
9617edfca9
msrv: bump to 1.45
2020-11-12 11:33:08 +00:00
Alex Gaynor
90a825d0c2
Merge branch 'master' into abi3-merge-master
2020-10-19 14:32:49 -04:00
David Hewitt
afd9b823d2
Drop support for Python 3.5
2020-10-18 19:02:27 +01:00
Alex Gaynor
ba6f0ecdfa
Merge branch 'master' into abi3-merge-master
2020-10-18 10:47:06 -04:00
Askaholic
6724783395
Change wording of PyDowncastError display implementation
...
Displays type(obj) instead of repr(obj) and uses `cannot` instead of
`can't`
to be more consistent with existing python error messages.
See discussion at #1212 .
2020-10-14 17:32:00 -08:00
Askaholic
19889bc6b9
Add argument name to TypeError messages caused during argument conversion
2020-10-14 17:32:00 -08:00
Askaholic
007bfb7ab0
Refactor py_expect_exception to also verify error string representation
2020-10-13 14:02:14 -08:00
Alex Gaynor
9e34835b76
Merge branch 'master' into abi3-merge-master
2020-10-12 18:03:14 -04:00
David Hewitt
7b3dd68bfb
Fix support for MSRV
...
Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
2020-10-12 15:46:40 +01:00
Alex Gaynor
aabad7cf7f
Assorted updates to the abi3 branch from review
2020-10-11 19:51:27 -04:00
Alex Gaynor
140790b15f
Merge branch 'master' into abi3-merge-master
2020-10-10 10:11:49 -04:00
kngwyu
e7092fe630
Make PyCFunction more backward-compatible
2020-10-09 01:35:55 +09:00
kngwyu
b42886a38a
Change PyCFunction to take &'static str as a function name
2020-10-08 17:26:55 +09:00
dvermd
df984ec8df
Keyword only arguments ( #1209 )
...
* allow keyword arguments without default value
* allow keyword-only arguments
2020-10-01 13:34:54 +09:00
Alex Gaynor
c22dd6c54c
Remove symbols not available in abi3
2020-09-23 22:30:07 -04:00
Yuji Kanagawa
e33e58fc72
Merge pull request #1201 from alex/abi3-text-signature
...
Hack __text_signature__ back to working with abi3
2020-09-20 16:46:04 +09:00
kngwyu
869a5e2f20
Fix an abi3 ui test for the latest Rustc
2020-09-20 15:33:55 +09:00
Alex Gaynor
9d8559158b
Hack __text_signature__ back to working with abi3
2020-09-19 11:43:57 -04:00
kngwyu
7644d67ad8
Inhibit subclassing native types with ABI3 set
2020-09-20 00:42:55 +09:00
Alex Gaynor
ba1056006a
Get all the tests building, everythign except doctests passes!
2020-09-16 08:42:22 -04:00
Alex Gaynor
5bfb4674b1
Merge branch 'master' into abi3-merge-master
2020-09-10 17:01:13 -04:00
David Hewitt
151af7a0b7
Merge pull request #1115 from davidhewitt/std-py-err
...
Implement std::error::Error for PyErr
2020-09-10 21:17:11 +01:00
David Hewitt
b9e95dc7c9
Implement std::error::Error for PyErr
2020-09-10 19:04:24 +01:00
kngwyu
7a4c5e2960
Merge branch 'master' into abi3
2020-09-10 00:48:20 +09:00
Sebastian Pütz
22881a3c2f
Change add_function, ensure static docstrings.
...
Change add_function to take `&PyCFunction` instead of a wrapper
fn and ensure that dostrings of functions are `&'static str`.
2020-09-09 12:37:37 +02:00
Alex Gaynor
117f60bed0
Make PyType::name abi3 compatible
...
The implementation is more complex, because there's no equivalent to tp_name in the limited API
2020-09-08 12:22:59 -04:00
Sebastian Pütz
be877d133f
Add constructor for PyCFunction.
2020-09-08 14:26:08 +02:00
Sebastian Pütz
2e8010b5df
Add native Function native types.
...
Add bindings for PyCFunction, PyFunction, PyClassMethod and
PyStaticMethod.
2020-09-08 09:51:31 +02:00
Sebastian Pütz
64b06ea9ec
Change `add_submodule()` to take `&PyModule`.
...
The C-exported wrapper generated through `#[pymodule]` is only
required for the top-level module.
2020-09-05 15:54:57 +02:00
Sebastian Pütz
e65b849ab6
Doc fixes, changelog and rename.
2020-09-05 10:20:22 +02:00
Sebastian Pütz
795c054511
Possible to pass PyModule as first arg.
...
This commit makes it possible to access the module of a function
by passing the `need_module` argument to the pyfn and pyfunction
macros.
2020-09-04 09:01:21 +02:00
Sebastian Pütz
3214249010
Make python function wrapper creation fallible.
...
Wrapping a function can fail if we can't get the module name.
Based on suggestion by @kngwyu
2020-09-03 15:48:32 +02:00
Sebastian Pütz
5bbca1a052
Set the module of `#[pyfunction]`s.
...
Previously neither the module nor the name of the module of
pyfunctions were registered. This commit passes the module and
its name when creating a new pyfunction.
PyModule::add_function and PyModule::add_module have been added and are
set to replace `add_wrapped` in a future release. `add_wrapped` is kept
for compatibility reasons during the transition.
Depending on whether a `PyModule` or `Python` is the argument for the
Python function-wrapper, the module will be registered with the function.
2020-09-03 14:49:28 +02:00
Alex Gaynor
400462063d
Proof of concept of using PEP384s PyType_Spec
2020-09-02 16:54:39 -04:00
Yuji Kanagawa
729f2f42e7
Merge pull request #1065 from sebpuetz/union
...
FromPyObject derivation for structs and enums
2020-08-31 21:28:49 +09:00
Sebastian Pütz
0f32f886b8
More FromPyObject derive suggestions by @davidhewitt
2020-08-30 19:16:59 +02:00
David Hewitt
82cb815afa
Use IntoPy<PyObject> for PyModule::add
2020-08-30 16:24:20 +01:00
Sebastian Pütz
7a9f4a1633
FromPyObject derive suggestions by @kngwyu
2020-08-30 15:33:50 +02:00
Sebastian Pütz
a8c5379eff
Add compile fail tests for FromPyObject derives + some fixes.
...
Fix some error messages and accidental passes.
2020-08-30 12:54:13 +02:00
Sebastian Pütz
7781bb78de
Specify item key and attr name as arguments.
2020-08-30 10:22:01 +02:00
Sebastian Pütz
60fe4925f5
'#[derive(FromPyObject)]` changes suggested by @davidwhewitt.
2020-08-30 10:22:01 +02:00
Sebastian Pütz
7168309464
Derive FromPyObject
2020-08-30 10:22:01 +02:00
David Hewitt
42296ea5c2
Update UI tests for Rust 1.46
2020-08-29 09:22:00 +01:00
Mario
608aea726c
Allow other Result types in `#[pyfunction]` ( #1118 )
...
* Added a couple basic tests
* Implemented suggested change
* Fixed type inference
* cargo fmt
* Finished tests and removed warnings
* Include in CHANGELOG.md
* Moved test into separate file
* &'static str and function rename
* Mention in the book
2020-08-29 08:25:20 +01: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
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
David Hewitt
a5ebef4b2e
Remove ObjectProtocol; Add methods to PyAny and use Deref
2020-05-08 10:05:19 +01:00
scalexm
d3d68eafb4
Add a test with class attrs returning `PyClass` instances
2020-05-07 21:25:27 +02:00
scalexm
8f22d10a14
Add a test showing that class attrs are immutable
2020-05-07 21:24:36 +02:00
scalexm
7b5a076680
Add `#[classattr]` methods to define Python class attributes
2020-05-07 21:23:47 +02:00
David Hewitt
9a2d908342
Simplify callback code using callback_body! macro
2020-05-05 00:27:50 +01:00
David Hewitt
dfbe22bb56
Thread-safe release pools
2020-05-02 13:16:22 +01:00
David Hewitt
3008528fa6
Allow use of `#[pyo3(get, set)]` with `Py<T>`
2020-04-22 22:21:27 +01:00
Mara Bos
dcab478d66
Fix lifetime safety bug of AsPyRef::as_ref(). ( #876 )
...
* Fix lifetime safety bug of AsPyRef::as_ref().
Fixes #875 .
* Add test for AsPyRef's lifetimes.
2020-04-20 18:44:31 +01:00
Martin Larralde
ed63902eeb
Modify existing `PyIteratorProtocol` tests to use `PyRef` where possible
2020-04-18 03:57:17 +02:00
Yuji Kanagawa
ae81865232
Apply suggestions from David
...
Co-Authored-By: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2020-04-13 11:05:48 +09:00
kngwyu
2cd466dc46
Bound 'py lifetime by GILPool when it's possible
2020-04-12 23:55:23 +09:00
Yuji Kanagawa
5e285fda78
Fix synchronization of datetime tests ( #867 )
...
* Fix synchronization of datetime tests
* Use Mutex instead of RawMutex
2020-04-11 19:10:16 +09:00
kngwyu
9dc3f9dc1a
Lock other threads before import datetime to avoid test failure
2020-04-09 22:11:03 +09:00
Martin Larralde
1e8e6fd827
Fix clippy warning about unused arguments in `tests/test_gc.rs`
2020-04-09 02:06:19 +02:00
Martin Larralde
5f2ec47bea
Add proper test for GC double borrow issue in `tp_traverse` wrapper
2020-04-09 00:52:49 +02:00