[New-bugs-announce] [issue44242] enum.IntFlag regression: missing values cause TypeError
Miro Hrončok
report at bugs.python.org
Wed May 26 15:31:43 EDT 2021
New submission from Miro Hrončok <miro at hroncok.cz>:
With the change introduced in https://bugs.python.org/issue38250 https://github.com/python/cpython/commit/7aaeb2a3d682ecba125c33511e4b4796021d2f82 I observe a regression in behavior of enum.IntFlag with missing values.
Consider this code (from pyproj):
from enum import IntFlag
class GeodIntermediateFlag(IntFlag):
DEFAULT = 0x0
NPTS_MASK = 0xF
NPTS_ROUND = 0x0
NPTS_CEIL = 0x1
NPTS_TRUNC = 0x2
DEL_S_MASK = 0xF0
DEL_S_RECALC = 0x00
DEL_S_NO_RECALC = 0x10
AZIS_MASK = 0xF00
AZIS_DISCARD = 0x000
AZIS_KEEP = 0x100
This is a valid code in Python 3.9, however produces a TypeError in Python 3.10.0b1:
Traceback (most recent call last):
File "intflag.py", line 3, in <module>
class GeodIntermediateFlag(IntFlag):
File "/usr/lib64/python3.10/enum.py", line 544, in __new__
raise TypeError(
TypeError: invalid Flag 'GeodIntermediateFlag' -- missing values: 4, 8, 32, 64, 128, 512, 1024, 2048
Since I don't see this behavior mentioned in https://docs.python.org/3.10/library/enum.html or https://docs.python.org/3.10/whatsnew/3.10.html or https://docs.python.org/3.10/whatsnew/changelog.html I believe this is a regression.
----------
components: Library (Lib)
messages: 394457
nosy: John Belmonte, Manjusaka, ethan.furman, hauntsaninja, hroncok, jbelmonte, veky
priority: normal
severity: normal
status: open
title: enum.IntFlag regression: missing values cause TypeError
type: behavior
versions: Python 3.10
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44242>
_______________________________________
More information about the New-bugs-announce
mailing list