This makes it possible to use rust keywords as the name of python class
methods and standalone functions. For example:
```
struct MyClass {
}
impl MyClass {
#[new]
fn new() -> Self {
MyClass {}
}
#[pyo3(name = "struct")]
fn struct_method(&self) -> usize {
42
}
}
fn struct_function() -> usize {
42
}
```
From the [`syn::Ident`
documentation](https://docs.rs/syn/2.0.66/syn/struct.Ident.html):
> An identifier constructed with `Ident::new` is permitted to be a Rust
keyword, though parsing one through its
[`Parse`](https://docs.rs/syn/2.0.66/syn/parse/trait.Parse.html)
implementation rejects Rust keywords. Use `input.call(Ident::parse_any)`
when parsing to match the behaviour of `Ident::new`.
Fixes issue #4225
* deprecate GIL Refs in function arguments
* fix deprecated gil refs in function arguments
* add notes on deprecations limitations to migration guide
* Apply suggestions from code review
Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
* review: Icxolu
* fix proto method extract failure for option
* fix gil refs in examples
---------
Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
* 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
* add `FromPyObjectBound` adjustment for `&str` without GIL Refs
* review: alex, Icxolu feedback
* add newsfragment
* add newsfragment for `FromPyObject` trait change
* make some examples compatible with abi3 < 3.10
* seal `FromPyObjectBound`
* fixup chrono_tz conversion
* Support Bound in pymodule and pyfunction macros
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
* Remove spurious $ character
Co-authored-by: Matthew Neeley <mneeley@gmail.com>
* Rework PyCFunction::new_bound signatures
This allows us to remove the awkward `PyFunctionArgumentsBound` enum.
* Use BoundRef instead of BoundModule
* support argument deduction for `wrap_pyfunction_bound!`
* support `wrap_pyfunction!` with `Bound` input/output
* Fix docs link to `wrap_pyfunction_bound!`
* Revert back to wrap_pyfunction!
---------
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
Co-authored-by: Matthew Neeley <mneeley@gmail.com>
* 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>
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.