Date 2020-01-25.06:30:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
(1) instantiation of an enumeration class with an invalid value
(2) a try/except around the instantiation where the exception is ignored

An unneeded reference to the bad value is lost (as well as other values that I suspect are local variables within a participating method)

When run, the attached sample script shows before and after reference counts which demonstrate the potential resource leaks. The sample script includes the output from running the script on Python version 3.7.5 within the module docstring.

The root cause appears to be in the exception handling in the Enum.__new__ method (in the area where it calls the _missing_ hook). The attached sample script includes a simplified version of those methods that should help pinpoint the code in question and confirm the root cause.

Not being an exception nitty-gritty expert, I have suspicions that users should be warned about using this pattern of exception handling. I suspect this pattern would be worth avoiding in the Enum implementation.

I am willing to take a stab at submitting a patch for Enum. I hesitate slightly not knowing if there are specific reasons for the code existing in its current form. Alternatively, I plan on being at PyCon2020 for the sprints and could be available then to work on it.
Date User Action Args
2020-01-25 06:30:33dan.gass@gmail.comsetrecipients: +
2020-01-25 06:30:33dan.gass@gmail.comsetmessageid: <>
2020-01-25 06:30:33dan.gass@gmail.comlinkissue39451 messages
2020-01-25 06:30:33dan.gass@gmail.comcreate