-
Notifications
You must be signed in to change notification settings - Fork 784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot implement __len__
classmethod (0.21+)
#4640
Comments
Defining |
Not unusual at all for certain types: from enum import Enum, auto
class MyEnum(Enum):
A = auto()
B = auto()
print(len(MyEnum)) # > 2 My use case is the same, creating a class in rust representing an enum (where |
In the I think you'll need #906 to be implemented to achieve this in PyO3. |
Or downgrade to |
Agreed this is a legitimate bug. From a quick test, it seems like Python allows most (all?) the dunder methods to be |
I attempted a fix in #4654. |
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 [email protected], pip install pyo3
Additional Info
No response
The text was updated successfully, but these errors were encountered: