添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

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

Bug report

Python enum fails equality test against itself after reloading using importlib.reload

Suppose we have a module:

# mod_enum.py
import enum
class E(enum.Enum):
    A = 'A'

In a Python shell:

>>> import importlib
>>> import mod_enum
>>> old_enum = mod_enum.E.A
>>> id(old_enum)
140661148711472
>>> importlib.reload(mod_enum)
<module 'mod_enum' from 'mod_enum.py'>
>>> new_enum = mod_enum.E.A
>>> id(new_enum)
140661156076320
>>> old_enum == new_enum
False

Your environment

  • CPython versions tested on: 3.8.10, 3.12.0
  • Operating system and architecture: Linux x86
  •