You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After updating crate to version 0.22.4, I got this error:
error[E0592]: duplicate definitions with name `__pymethod_clear__`
--> src/bridge/cache.rs:21:1
|
21 | #[pyo3::pymethods]
| ^^^^^^^^^^^^^^^^^^
| |
| duplicate definitions for `__pymethod_clear__`
| other definition for `__pymethod_clear__`
|
= note: this error originates in the attribute macro `pyo3::pymethods` (in Nightly builds, run with -Z macro-backtrace for more info)
This is my code:
#[pyo3::pyclass(name="Cache")]pubstructCache{// fields ...}#[pyo3::pymethods]implCache{pubfn__traverse__(&self,visit: pyo3::PyVisit<'_>) -> Result<(), pyo3::PyTraverseError>{// some code ...Ok(())}pubfn__clear__(&self){// some code ...}#[pyo3(signature=(*, reuse=false))]pubfnclear(&self,reuse:bool){// some code ...}}
I know this is because I have __clear__ and clear methods together, but this was OK before, and now I cannot remove or change them. How can I fix that?
Steps to Reproduce
Initialize a PyO3 project with maturin init
Write this code in src/lib.rs:
use pyo3::prelude::*;#[pyo3::pyclass(name="Cache")]pubstructCache{}#[pyo3::pymethods]implCache{pubfn__traverse__(&self,visit: pyo3::PyVisit<'_>) -> Result<(), pyo3::PyTraverseError>{Ok(())}pubfn__clear__(&self){}#[pyo3(signature=(*, reuse=false))]pubfnclear(&self,reuse:bool){}}/// A Python module implemented in Rust.#[pymodule]fnpy_test_pyo3(m:&Bound<'_,PyModule>) -> PyResult<()>{
m.add_class::<Cache>()?;Ok(())}
You will see this error (run maturin develop):
error[E0592]: duplicate definitions with name `__pymethod_clear__`
--> src/lib.rs:8:1
|
8 | #[pyo3::pymethods]
| ^^^^^^^^^^^^^^^^^^
| |
| duplicate definitions for `__pymethod_clear__`
| other definition for `__pymethod_clear__`
|
= note: this error originates in the attribute macro `pyo3::pymethods` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> src/lib.rs:9:6
|
8 | #[pyo3::pymethods]
| ------------------ arguments to this function are incorrect
9 | impl Cache {
| ______^
10 | | pub fn __traverse__(&self, visit: pyo3::PyVisit<'_>) -> Result<(), pyo3::PyTraverseError> {
11 | | // some code ...
12 | | Ok(())
... |
19 | | #[pyo3(signature=(*, reuse=false))]
20 | | pub fn clear(&self, reuse: bool) {
| |________________^ expected "Rust" fn, found "C" fn
|
= note: expected fn pointer `unsafe for<'py> fn(Python<'py>, *mut PyObject, *const *mut PyObject, isize, *mut PyObject) -> Result<*mut PyObject, PyErr>`
found fn item `unsafe extern "C" fn(*mut PyObject) -> i32 {Cache::__pymethod_clear__}`
note: function defined here
--> /home/awolverp/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pyo3-0.22.4/src/impl_/trampoline.rs:56:12
|
56 | pub fn fastcall_with_keywords(
| ^^^^^^^^^^^^^^^^^^^^^^
Some errors have detailed explanations: E0308, E0592.
For more information about an error, try `rustc --explain E0308`.
warning: `py-test-pyo3` (lib) generated 2 warnings
error: could not compile `py-test-pyo3` (lib) due to 2 previous errors; 2 warnings emitted
💥 maturin failed
Caused by: Failed to build a native library through cargo
Caused by: Cargo build finished with "exit status: 101": `env -u CARGO PYO3_ENVIRONMENT_SIGNATURE="cpython-3.12-64bit" PYO3_PYTHON="/home/awolverp/Projects/py-test-pyo3/.venv/bin/python" PYTHON_SYS_EXECUTABLE="/home/awolverp/Projects/py-test-pyo3/.venv/bin/python" "cargo" "rustc" "--features" "pyo3/extension-module" "--message-format" "json-render-diagnostics" "--manifest-path" "/home/awolverp/Projects/py-test-pyo3/Cargo.toml" "--lib"`
Backtrace
No response
Your operating system and version
Linux awolverp-82h8 6.10.13-3-MANJARO #1 SMP PREEMPT_DYNAMIC Tue Oct 8 03:24:49 UTC 2024 x86_64 GNU/Linux
Your Python version (python --version)
Python 3.12.6
Your Rust version (rustc --version)
rustc 1.81.0 (eeb90cda1 2024-09-04)
Your PyO3 version
0.22.4
How did you install python? Did you use a virtualenv?
Python is installed by default
Yes, I used virtualenv.
Additional Info
No response
The text was updated successfully, but these errors were encountered:
Ooof, yes this is a regression. Should be easy to fix; I think I will have to ship a 0.22.5 given that we yanked all the rest of 0.22 except for 0.22.4.
Bug Description
After updating crate to version 0.22.4, I got this error:
This is my code:
I know this is because I have
__clear__
andclear
methods together, but this was OK before, and now I cannot remove or change them. How can I fix that?Steps to Reproduce
maturin init
src/lib.rs
:maturin develop
):Backtrace
No response
Your operating system and version
Linux awolverp-82h8 6.10.13-3-MANJARO #1 SMP PREEMPT_DYNAMIC Tue Oct 8 03:24:49 UTC 2024 x86_64 GNU/Linux
Your Python version (
python --version
)Python 3.12.6
Your Rust version (
rustc --version
)rustc 1.81.0 (eeb90cda1 2024-09-04)
Your PyO3 version
0.22.4
How did you install python? Did you use a virtualenv?
Python is installed by default
Yes, I used
virtualenv
.Additional Info
No response
The text was updated successfully, but these errors were encountered: