Sebastian Höfer <sebastian.hoe...@gmail.com> added the comment: I ran into the same issue and while I see that this is not a bug I would suggest that this behaviour at least deserves a warning in the documentation under https://docs.python.org/3/library/enum.html#comparisons
This unexpected behaviour can not only occur with messed up imports, but also when a module uses the importlib.reload() function and submodules are reloaded during runtime. I attached a minimal working example. In our case we have a central module where all constants, dataclasses and enums are defined. A main program imports several submodules which all import these datatypes. Reloading a submodule results in new object ids for the enums in this submodule and comparing data between different modules suddenly results in inconsistent behaviour. It took a while to debug, because except for the object id the enums look exactly the same and before reading this thread I did not realize that the comparison is actually done by object ids. ---------- nosy: +Sebastian Höfer Added file: https://bugs.python.org/file47936/enum_reload_example.zip _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue30545> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com