Code Apprentice
79591f2161
Add error messages for unsupported macro features on compilation ( #4194 )
...
* First implementation
* tweak error message wording
* Fix boolean logic
* Remove redundant parens
* Add test for weakref error
* Fix test
* Reword error message
* Add expected error output
* Rinse and repeat for `dict`
* Add test output file
* Ignore Rust Rover config files
* cargo fmt
* Add newsfragment
* Update newsfragments/4194.added.md
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
* Use ensure_spanned! macro
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
* Use ensure_spanned! macro for weakref error, too
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
* Revert "Ignore Rust Rover config files"
This reverts commit 6c8a2eec581ed250ec792d8465772d649b0a3199.
* Update wording for error message
Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
* Update weakref error message, too
* Refactor constant to a pyversions module
* Fix compiler errors
* Another wording update
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
* And make weakref wording the same
* Fix compiler error due to using weakref in our own code
* Fix after merge
* apply conditional pyclass
* update conditional compilation in tests
---------
Co-authored-by: cojmeister <luqas.c@gmail.com>
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
2024-06-16 10:23:03 +00:00
Icxolu
ee89b2e8e2
deprecate `wrap_pyfunction` with `py` argument ( #3954 )
...
* deprecate `wrap_pyfunction` with `py` argument
The Python token in `wrap_pyfunction` is not handled automatically by
`WrapPyFunctionArg`, for backwards compatibility. This uses deref
specialization to deprecate this variant.
* merge `Extractor`s
* add deprecation ui test, revert closure variant due to test failure
* fix nightly
2024-03-12 22:57:03 +00:00
Icxolu
70a7aa808d
deprecate the use of `PyCell` in favor of `Bound` and `Py` ( #3916 )
...
* deprecate the use of `PyCell` in favor of `Bound` and `Py`
* update `FromPyObject` for `T: PyClass + Clone` impl
* move `PyCell` deprecation to the `gil-refs` feature gate and add a migration note
2024-03-03 14:47:25 +00:00
David Hewitt
9e74c858c2
add `PyModule::new_bound` and `PyModule::import_bound` ( #3775 )
...
* add `PyModule::new` and `PyModule::import_bound`
* review: Icxolu feedback
2024-02-22 09:35:47 +00:00
Icxolu
61bc02d927
deprecate `PyCell::new` in favor of `Py::new` or `Bound::new` ( #3872 )
...
* deprecate `PyCell::new` in favor of `Py::new` or `Bound::new`
* update deprecation warning
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
---------
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
2024-02-20 07:45:47 +00:00
David Hewitt
4efc4b82a3
ci: fix redundant import warnings on nightly ( #3873 )
2024-02-19 22:07:05 +00:00
Lily Foote
0dd568d397
Use the new bound API instead of .as_ref(py) ( #3853 )
...
* Use the new bound API instead of .as_ref(py)
* Move import into a nested scope
* Use to_cow instead of to_str for compatibility
`to_str` is not available before Python 3.10 on the limited api.
* Relax &self lifetimes
* Use Bound<'py, PyAny> in test Mapping signatures
* Use .as_bytes(py)
* Simplify ThrowCallback::throw signature
* Avoid .as_any call with Py api instead of Bound
2024-02-18 00:09:56 +00:00
Icxolu
0c12d9137f
port `Python::import` to `Bound` API ( #3832 )
...
* port `Python::import` to `Bound` API
* tidy up imports in tests/test_datetime_import.rs
---------
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
2024-02-14 00:24:37 +00:00
David Hewitt
53d25f7ff2
add new `PyTuple` constructors
2023-12-30 21:37:46 +00:00
David Hewitt
7d486bb72a
tests/common.rs -> src/tests/common.rs
2023-09-24 13:34:53 +01:00
David Hewitt
8a60540e25
amend code for `PyDict::get_item` change
2023-09-09 12:23:06 +01:00
mejrs
984fdf57c7
Use Python:;with_gil in tests
2022-07-19 19:34:23 +02:00
mejrs
6f1cf1b662
Add more lints
2022-03-23 08:07:28 +01:00
David Hewitt
6433d884fc
dev: remove self dev dependency
2021-12-08 07:48:58 +00:00
messense
b5b9a480cd
Add `wrap_pyfunction` macro to prelude
2021-06-24 22:34:55 +08:00
kngwyu
9b88a452e2
Refactor tests to use shorter macros
2021-03-14 23:43:53 +09:00
David Hewitt
b2675b11fe
rust 1.50: clippy and lint fixes
2021-02-11 22:03:34 +00:00
David Hewitt
7572962828
abi3: add support for dict and weakref from Python 3.9
2020-12-28 10:22:46 +00:00
Alex Gaynor
ba1056006a
Get all the tests building, everythign except doctests passes!
2020-09-16 08:42:22 -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
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
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
David Hewitt
77ed6d6d69
Remove AsPyRef for just Py::as_ref
2020-08-09 22:47:54 +01:00
David Hewitt
e72b682038
Remove redundant iter test
2020-08-07 13:49:52 +01:00
kngwyu
8f8b42591a
Fix PySelf and AsPyRef
2020-02-16 23:54:55 +09:00
kngwyu
a2408cacbb
Rename PyClassShell with PyCell
2020-02-08 15:05:13 +09:00
David Hewitt
7531b9fb07
Remove even more uses of `static mut`
2020-01-30 13:24:55 +00:00
kngwyu
302b3bb088
Merge branch 'master' into pyclass-new-layout
2020-01-11 15:03:25 +09:00
Alexander Niederbühl
1f675dcaa7
Clear error indicator when the exception is handled on the Rust side
...
Leaving Python's global exception state is misleading, e.g. subsequent
calls of `py.eval` will fail.
2020-01-11 00:44:11 +01:00
kngwyu
a6639076b9
Introduce PyInternalCaster
2019-12-14 23:16:39 +09:00
Samuele Maci
0aa02f715f
Address clippy::into_iter_on_array issues
2019-08-17 14:10:36 +02:00
Daniël de Kok
ac28a3114b
Fix NULL pointer deref when creating iterator for non-iterable
...
Fixes #494 .
2019-07-27 19:58:18 +02:00
kngwyu
0f9a3b1194
Expose py_run macro
2019-06-13 18:18:06 +09:00
kngwyu
4bf448ecaa
Complete the PR
2019-05-25 23:19:07 +09:00
Alexander Niederbühl
299d325375
Enable setting the module name of a class
...
This is relevant for pickling objects.
2019-05-08 23:39:22 +02:00
Miles Granger
711155d7ad
Update tests & docs with IntoPyDict::into_py_dict(py)
2019-03-20 20:04:00 +01:00
konstin
6cd07c369c
Simpler new and clippy fixes
2019-02-23 18:38:00 +01:00
konstin
d02f7c3aa5
Big proc macro refactoring
...
* Removed a lot of clutter, unified some code
* Started using syn::parse::Parse for pyfunction attributes
* No more newlines between imports
* Renamed `#[prop(get, set)]` to `#[pyo3(get, set)]`
* `#[pyfunction]` now supports the same arguments as `#[pyfn()]`
* Some macros now emit proper spanned errors instead of panics.
2019-02-18 20:07:56 +01:00
konstin
2105fa896b
Add PyTuple tests
...
Initially proposed by athre0z in #307 , with the changes from latest master
2019-02-13 22:30:46 +01:00
konstin
6cb098ee12
Replace py.init_[ref|mut] with Py[Ref|Mut]::new
2019-02-13 21:52:21 +01:00
konstin
1a489d2829
Make the init methods use a value instead of a function
2019-02-13 13:59:47 +01:00
konstin
9e53418aad
Less feature(specialization)
2019-02-01 18:09:51 +01:00
konstin
936f0153e8
Migrate to rust 2018
2019-02-01 14:23:29 +01:00
konstin
57afb51604
Remove PyToken completely; Fixes #94
2018-11-12 14:42:21 +01:00
konstin
fb2349b6ec
Remove PyToken usages from tests
2018-11-12 14:41:29 +01:00
konstin
302c099a76
Big refactoring to shrink the prelude
2018-09-21 23:34:28 +02:00
konstin
d92e522243
Syn 0.15
2018-09-09 00:20:04 +02:00
konstin
991a8b94d2
More nightly fixes
2018-08-19 20:42:17 +02:00
konstin
d59bebcc38
Upgrade from proc_macro to use_extern_macros
2018-07-18 13:08:05 +02:00