Skip to content

Enum does not equal to itself after importlib.reload #96858

Closed as not planned
Closed as not planned
@ak1r4

Description

@ak1r4

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions