Message390095
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.] |
|
Date |
User |
Action |
Args |
2021-04-02 20:22:45 | mark.dickinson | set | recipients:
+ mark.dickinson, ethan.furman, efroemling, gerald.dalley2 |
2021-04-02 20:22:45 | mark.dickinson | set | messageid: <1617394965.77.0.911700223253.issue42248@roundup.psfhosted.org> |
2021-04-02 20:22:45 | mark.dickinson | link | issue42248 messages |
2021-04-02 20:22:45 | mark.dickinson | create | |
|