Mark Dickinson <dicki...@gmail.com> added the comment:
Here's a cut-down example, at the prompt: Python 3.9.2 (default, Mar 31 2021, 05:47:22) [Clang 11.0.3 (clang-1103.0.32.62)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import signal >>> class App: pass ... >>> def create_app(): ... app = App() ... signal.signal(signal.SIGINT, signal.SIG_DFL) ... >>> create_app() At this point, since the App() instance was local to create_app, and wasn't returned, I'd expect there to be no App objects alive in the system. But it turns out there's still an App object being kept alive: >>> import gc >>> [obj for obj in gc.get_objects() if type(obj) is App] [<__main__.App object at 0x10acb3d90>] The cause is a call to _int_to_enum in signal.py which attempts to coerce the default signal handler to an element of Handlers. That coercion fails, leaving an exception ValueError('<built-in function default_int_handler> is not a valid Handlers') The traceback on that exception leads to the frame containing the call to Enum.__new__, which in turn contains a reference ve_exc back to the exception. [In the real code, App was a wx.App object, and the App.__init__ method played the role of create_app.] ---------- _______________________________________ 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