Open timkpaine opened 23 hours ago
This used to work in pyo3<0.21:
pyo3<0.21
#[classmethod] fn __len__(cls: &Bound<'_, PyType>) -> PyResult<usize> { Ok(0) }
error[E0425]: cannot find value `_slf_ref` in this scope --> lib1-py/src/lib.rs:15:1 | 15 | #[pymethods] | ^^^^^^^^^^^^ not found in this scope
Include the above block in any #[pymethods] block
#[pymethods]
macOS 15.0.1
python --version
Python 3.11.10
rustc --version
rustc 1.79.0 (129f3b996 2024-06-10)
0.22.5
brew install python@3.11, pip install pyo3
No response
Defining __len__ as a @classmethod seems very unusual to me. What's your use case?
__len__
@classmethod
Bug Description
This used to work in
pyo3<0.21
:Steps to Reproduce
Include the above block in any
#[pymethods]
blockBacktrace
Your operating system and version
macOS 15.0.1
Your Python version (
python --version
)Python 3.11.10
Your Rust version (
rustc --version
)rustc 1.79.0 (129f3b996 2024-06-10)
Your PyO3 version
0.22.5
How did you install python? Did you use a virtualenv?
brew install python@3.11, pip install pyo3
Additional Info
No response