New submission from Eric Froemling <ericfroeml...@gmail.com>:
I've run into an issue where exceptions thrown by Enum constructors are keeping my objects alive. The underlying issue seems to be the same as https://bugs.python.org/issue36820 The same method used to fix the issue above seems to work here: simply adding a try/finally clause around the error handling at the end of enum.Enum.__new__() which sets ve_exc and exc to None does the trick. I've attached a short script which demonstrates the issue. I realize that the cyclic garbage collector will eventually handle this case, but its a bummer to lose determinism in the destruction of my objects. I'd be happy to create a PR for this or whatever I can do to help; just let me know if I should (I'm new here). ---------- components: Library (Lib) files: enum_ref_loop_example.py messages: 380249 nosy: efroemling priority: normal severity: normal status: open title: Raised exception in Enum keeping user objects alive unnecessarily versions: Python 3.8 Added file: https://bugs.python.org/file49564/enum_ref_loop_example.py _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue42248> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com