-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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
enum.IntFlag (un)pickles incorrectly on Python 3.12 (and differently on Python 3.11) #105332
Comments
The same also happens with import enum
import pickle
class PxdEnum(enum.Flag):
RANK_0 = 11
RANK_1 = 37
RANK_2 = 389
d = pickle.dumps(PxdEnum.RANK_2)
print('--')
print(pickle.loads(d)) The offending commit is 5369858 I am working on a fix! Thanks for the report. |
@da-woods in Python 3.11.3 (main, May 27 2023, 12:23:35) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import enum
>>> import pickle
>>>
>>> class PxdEnum(enum.IntFlag):
... RANK_0 = 11
... RANK_1 = 37
... RANK_2 = 389
...
>>> print(pickle.loads(pickle.dumps(PxdEnum.RANK_2)))
389
>>> print(type(pickle.loads(pickle.dumps(PxdEnum.RANK_2))))
<flag 'PxdEnum'> |
Thanks for the quick PR. The change in representation wasn't a big worry - it didn't break anything for me. It was just something I spotted while preparing the checking the example and wasn't sure if it was relevant or not. |
* revert enum pickling from by-name to by-value Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
This looks like it was fixed. Should I close the issue or is it waiting for anything? |
Yes, it is fixed. Thanks for the report! |
Bug report
Run the following code:
On Python 3.10.10 I get
PxdEnum.RANK_2
On Python 3.11.2 I get
389
(which is probably also acceptable)On Python 3.12 (0aaef83351473e8f4eb774f8f999bbe87a4866d7) I get
Your environment
Tested as described on Python 3.10, 3.11, and 3.12.
Linux
Linked PRs
The text was updated successfully, but these errors were encountered: