Skip to content
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 now unpickles incorrectly on Python 3.11.4 #105837

Closed
da-woods opened this issue Jun 15, 2023 · 4 comments
Closed

enum.IntFlag now unpickles incorrectly on Python 3.11.4 #105837

da-woods opened this issue Jun 15, 2023 · 4 comments
Assignees
Labels
3.11 only security fixes pending The issue will be closed if no feedback is provided stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@da-woods
Copy link
Contributor

Bug report

Follow up to #105332

Following the changes to fix that issue enum.IntFlag appears to pickle correctly on the latest Python 3.12 commit (dd36656ada05731c069ecd5b1878380294fb1f3e) but fail on Python 3.11.4 (where on 3.11.2 it worked)

Code to reproduce

import enum
import pickle

class PxdEnum(enum.IntFlag):
    RANK_0 = 11
    RANK_1 = 37
    RANK_2 = 389

pickled = pickle.dumps(PxdEnum.RANK_2)

print(pickle.loads(pickled))

error output:

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

Your environment

64 bit Linux, Python 3.11.4

@da-woods da-woods added the type-bug An unexpected behavior, bug, or error label Jun 15, 2023
@da-woods
Copy link
Contributor Author

Just as background for this, in Cython we're converting C enums in enum.IntFlags when they're passed back to Python. One of the tests we have is that our converted enums can be pickled and unpickled, and this test is now failing. (Although it can be easily demonstrated outside Cython, as in the reproducible example above)

@AlexWaygood AlexWaygood added stdlib Python modules in the Lib dir 3.11 only security fixes labels Jun 15, 2023
@sobolevn
Copy link
Member

This was solved in #105348

Can you please verify?

@sobolevn sobolevn added the pending The issue will be closed if no feedback is provided label Jun 16, 2023
@da-woods
Copy link
Contributor Author

Sorry - I think you're right. I'd thought that the fix was in 3.11.4 but looking at the commit history the fix was just after 3.11.4.

I'll double check later today, but I suspect this is a false alarm caused by me not realising what has included in the release

@da-woods
Copy link
Contributor Author

Yes - sorry - it's fixed on the Python 3.11 branch. I'd got slightly confused about what was in the 3.11.4 release.

I'll close this issue. Sorry for the noise.

@AlexWaygood AlexWaygood closed this as not planned Won't fix, can't repro, duplicate, stale Jun 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11 only security fixes pending The issue will be closed if no feedback is provided stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

4 participants