Bug report
Bug description:
The type of path used to import an Enum affects whether it equals itself or not.
Assume we have a tests directory in our project, and in it are enums1.py and test_enums.py
enums1.py:
import enum
class Color(enum.Enum):
RED = 1
GREEN = 2
BLUE = 3
tests_enums.py:
import enums1
import tests.enums1
d1 = {c: c.name for c in enums1.Color}
print(id(enums1.Color.RED))
print(id(tests.enums1.Color.RED))
print(enums1.Color.RED == tests.enums1.Color.RED)
print(d1[tests.enums1.Color.RED])
running test_enums.py results in two distrinct ids for Color.Red, it says enums1.Color.RED does not equal tests.enums1.Color.RED, and there's a KeyError on the final line.
Expected behavior:
The import path should not affect whether the same enum is equal to itself. there should have been two identical ids, Color.RED should equal Color.RED and there should not be a KeyError.
CPython versions tested on:
3.12
Operating systems tested on:
Linux