-
Notifications
You must be signed in to change notification settings - Fork 940
Description
Bug Description
In versions <0.28 we have found ways to pickle complex enums of any form (see discussion #5226). The one thing necessary in Python was to monkey-patch the namespace (otherwise Python's native pickling functionality would not generate the right objects). E.g. I required:
mymodule.rs.MyEnum_A = mymodule.rs.MyEnum.A
mymodule.rs.MyEnum_B = mymodule.rs.MyEnum.B
mymodule.rs.MyEnum_C = mymodule.rs.MyEnum.C0.28 broke many of the pickling tests. The solution was to adjust the above to:
mymodule.rs.A = mymodule.rs.MyEnum.A
mymodule.rs.B = mymodule.rs.MyEnum.B
mymodule.rs.C = mymodule.rs.MyEnum.CBut this doesn't seem like a very good idea because of a potential name overlap with two different Enums. Fortunately we had no overlap and our code can update to 0.28 as is but if we were to have had: MyEnum.A and MyEnum2.A then we cannot do the above because mymodule.rs.A cannot be dual assigned.
You can see our 0.28 upgrade PR here: attack68/rateslib#1212
Steps to Reproduce
Create a complex enum as pyclass and examine the namespace constructed in Python for your module.
Backtrace
Your operating system and version
windows
Your Python version (python --version)
3.10+
Your Rust version (rustc --version)
1.87
Your PyO3 version
0.28
How did you install python? Did you use a virtualenv?
python -m venv
Additional Info
No response