Repository navigation
enum with inherited type won't pickle #88508
Copy link
Copy link
Closed
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.8 (EOL)end of lifeend of life3.9 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee = 'https://github.com/ethanfurman'
closed_at = <Date 2021-06-19.21:53:03.719>
created_at = <Date 2021-06-08.00:56:53.414>
labels = ['type-bug', '3.8', '3.9', '3.10', '3.11', 'library']
title = "enum with inherited type won't pickle"
updated_at = <Date 2021-06-19.21:53:03.718>
user = 'https://bugs.python.org/TomBrown'bugs.python.org fields:
activity = <Date 2021-06-19.21:53:03.718>
actor = 'ethan.furman'
assignee = 'ethan.furman'
closed = True
closed_date = <Date 2021-06-19.21:53:03.719>
closer = 'ethan.furman'
components = ['Library (Lib)']
creation = <Date 2021-06-08.00:56:53.414>
creator = 'Tom.Brown'
dependencies = []
files = []
hgrepos = []
issue_num = 44342
keywords = ['patch']
message_count = 10.0
messages = ['395300', '395578', '395585', '395589', '395609', '395613', '395615', '395898', '395902', '395903']
nosy_count = 3.0
nosy_names = ['ethan.furman', 'Tom.Brown', 'miss-islington']
pr_nums = ['26658', '26660', '26666', '26667', '26726', '26746', '26747', '26750']
priority = 'high'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue44342'
versions = ['Python 3.8', 'Python 3.9', 'Python 3.10', 'Python 3.11']Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.8 (EOL)end of lifeend of life3.9 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
TomBrown commentedon Jun 8, 2021
The following script runs without error in 3.8.5 and raises an error in 3.8.6, 3.9.5 and 3.10.0b1.
Source:
Error (same in 3.8.6, 3.9.5 and 3.10.0b1):
Like https://bugs.python.org/issue41889 this seems to be related to the fix for https://bugs.python.org/issue39587 which changes member_type from int to MyInt. A work-around is in the comment above.
ethanfurman commentedon Jun 10, 2021
Looking into this I think the root of the problem is the way
reduceis handled -- currently, Enum's__reduce_ex__works by returning the class, and the value to use to lookup the member. Because that lookup can fail with complex enums, EnumType will sabotagereduceif it can't find support in the new enum class.However, if
__reduce_ex__working by returningthen we should be fine, as that should never fail.
ethanfurman commentedon Jun 10, 2021
New changeset 62f1d2b by Ethan Furman in branch 'main':
bpo-44342: [Enum] changed pickling from by-value to by-name (GH-26658)
62f1d2b
ethanfurman commentedon Jun 10, 2021
New changeset b613132 by Miss Islington (bot) in branch '3.10':
bpo-44342: [Enum] changed pickling from by-value to by-name (GH-26658) (GH-26660)
b613132
ethanfurman commentedon Jun 11, 2021
Changing
__reduce_ex__is too big a change for 3.9, so making the search for pickle support more robust there.ethanfurman commentedon Jun 11, 2021
New changeset 3a7cccf by Ethan Furman in branch 'main':
bpo-44342: [Enum] fix data type search (GH-26667)
3a7cccf
ethanfurman commentedon Jun 11, 2021
Also fixing the search for the data type so that in
A -> B -> C
the data type is C and not B.
ethanfurman commentedon Jun 15, 2021
New changeset 0f99324 by Miss Islington (bot) in branch '3.10':
bpo-44342: [Enum] fix data type search (GH-26667)
0f99324
ethanfurman commentedon Jun 16, 2021
New changeset 41c2a4a by Ethan Furman in branch '3.10':
[3.10] bpo-44342: [Enum] improve test, add andrei kulakov to ACKS (GH-26726)
41c2a4a
ethanfurman commentedon Jun 16, 2021
New changeset 741b8ae by Ethan Furman in branch 'main':
bpo-44342: [Enum] sync current docs to 3.10 (GH-26750)
741b8ae