This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients efroemling, ethan.furman, gerald.dalley2, mark.dickinson
Date 2021-04-02.20:22:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1617394965.77.0.911700223253.issue42248@roundup.psfhosted.org>
In-reply-to
Content
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.]
History
Date User Action Args
2021-04-02 20:22:45mark.dickinsonsetrecipients: + mark.dickinson, ethan.furman, efroemling, gerald.dalley2
2021-04-02 20:22:45mark.dickinsonsetmessageid: <1617394965.77.0.911700223253.issue42248@roundup.psfhosted.org>
2021-04-02 20:22:45mark.dickinsonlinkissue42248 messages
2021-04-02 20:22:45mark.dickinsoncreate