Activity log for bug #1177857

Date Who What changed Old value New value Message
2013-05-08 16:07:55 Matthew Lefavor bug added bug
2013-05-08 16:11:55 Matthew Lefavor description I am running Python 3.3. When I create an IntEnum, the IntEnumValue members are not hashable. I do not have this problem with Python 2.7, or with regular enums. Consider this example interactive session with Python3: >>> import flufl.enum >>> MyEnum = flufl.enum.Enum("MyEnum", "a b c d") >>> hash(MyEnum.a) 268880433 >>> MyIntEnum = flufl.enum.Enum("MyIntEnum", "a b c d") >>> hash(MyIntEnum.a) 269549637 >>> MyIntEnum = flufl.enum.IntEnum("MyIntEnum", "a b c d") >>> hash(MyIntEnum.a) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unhashable type: 'IntEnumValue' Running the same code in Python 2 will not cause an error. This is an issue because it prevents IntEnum objects from being used as dictionary keys. It also prevents constructions like my_value = MyIntEnum(x) when it is not clear whether x is an IntEnumValue or an integer. I am running Python 3.3. When I create an IntEnum, the IntEnumValue members are not hashable. I do not have this problem with Python 2.7, or with regular enums. Consider this example interactive session with Python3: >>> import flufl.enum >>> MyEnum = flufl.enum.Enum("MyEnum", "a b c d") >>> hash(MyEnum.a) 268880433 >>> MyIntEnum = flufl.enum.IntEnum("MyIntEnum", "a b c d") >>> hash(MyIntEnum.a) Traceback (most recent call last):   File "<stdin>", line 1, in <module> TypeError: unhashable type: 'IntEnumValue' Running the same code in Python 2 will not cause an error. This is an issue because it prevents IntEnum objects from being used as dictionary keys. It also prevents constructions like my_value = MyIntEnum(x) when it is not clear whether x is an IntEnumValue or an integer.
2013-05-08 16:22:09 Matthew Lefavor description I am running Python 3.3. When I create an IntEnum, the IntEnumValue members are not hashable. I do not have this problem with Python 2.7, or with regular enums. Consider this example interactive session with Python3: >>> import flufl.enum >>> MyEnum = flufl.enum.Enum("MyEnum", "a b c d") >>> hash(MyEnum.a) 268880433 >>> MyIntEnum = flufl.enum.IntEnum("MyIntEnum", "a b c d") >>> hash(MyIntEnum.a) Traceback (most recent call last):   File "<stdin>", line 1, in <module> TypeError: unhashable type: 'IntEnumValue' Running the same code in Python 2 will not cause an error. This is an issue because it prevents IntEnum objects from being used as dictionary keys. It also prevents constructions like my_value = MyIntEnum(x) when it is not clear whether x is an IntEnumValue or an integer. I am running Python 3.3. When I create an IntEnum, the IntEnumValue members are not hashable. I do not have this problem with Python 2.7, or with regular enums. Consider this example interactive session with Python3: >>> import flufl.enum >>> MyEnum = flufl.enum.Enum("MyEnum", "a b c d") >>> hash(MyEnum.a) 268880433 >>> MyIntEnum = flufl.enum.IntEnum("MyIntEnum", "a b c d") >>> hash(MyIntEnum.a) Traceback (most recent call last):   File "<stdin>", line 1, in <module> TypeError: unhashable type: 'IntEnumValue' Running the same code in Python 2 will not cause an error. This is an issue because it prevents IntEnum objects from being used as dictionary keys. In particular, the dictionary problem makes code like the following crash when it shouldn't (because it appears some internal code is trying to look up the value in a dictionary): >>> MyIntEnum(MyIntEnum.a) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/flufl/enum/_enum.py", line 120, in __call__ return cls.__getitem__(args[0]) File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/flufl/enum/_enum.py", line 102, in __getitem__ attr = cls._enums.get(item) TypeError: unhashable type: 'IntEnumValue'
2014-04-24 15:23:15 Barry Warsaw flufl.enum: status New Won't Fix