Skip to content

enum.IntFlag (un)pickles incorrectly on Python 3.12 (and differently on Python 3.11) #105332

@da-woods

Description

@da-woods

Bug report

Run the following code:

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))) 

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

Traceback (most recent call last): File "<path>/enumpickle.py", line 9, in <module> print(pickle.loads(pickle.dumps(PxdEnum.RANK_2))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: unsupported operand type(s) for |: 'PxdEnum' and 'NoneType' 

Your environment

Tested as described on Python 3.10, 3.11, and 3.12.
Linux

Linked PRs

Metadata

Metadata

Assignees

Labels

3.12only security fixes3.13bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions