Issue 24596: Script globals in a GC cycle not finalized when exiting with SystemExit (original) (raw)
Issue24596
Created on 2015-07-09 13:31 by petr.viktorin, last changed 2022-04-11 14:58 by admin. This issue is now closed.
Pull Requests | |||
---|---|---|---|
URL | Status | Linked | Edit |
PR 7918 | merged | ZackerySpytz,2018-06-25 22:59 | |
PR 8069 | merged | miss-islington,2018-07-03 19:48 | |
PR 8070 | merged | miss-islington,2018-07-03 19:48 |
Messages (6) | ||
---|---|---|
msg246491 - (view) | Author: Petr Viktorin (petr.viktorin) * ![]() |
Date: 2015-07-09 13:31 |
When this program is invoked as a script (`python reproducer.py`), the __del__ is never called: --- class ClassWithDel: def __del__(self): print('__del__ called') a = ClassWithDel() a.link = a raise SystemExit(0) --- Raising a different exception, moving the code to a function, importing the module, or invoking with -m (or even -c), causes __del__ to be called normally. | ||
msg246498 - (view) | Author: Antoine Pitrou (pitrou) * ![]() |
Date: 2015-07-09 13:55 |
It's likely that your global variable gets caught in the traceback attached to the SystemExit, and that either never gets deallocated, or gets deallocated too late. | ||
msg246502 - (view) | Author: Antoine Pitrou (pitrou) * ![]() |
Date: 2015-07-09 14:10 |
Actually, the problem is in PyRun_SimpleFileExFlags(). The executed module is decref'ed after calling PyErr_Print(), but the latter never returns when the exception is a SystemExit. | ||
msg321001 - (view) | Author: Antoine Pitrou (pitrou) * ![]() |
Date: 2018-07-03 19:47 |
New changeset d8cba5d16f1333fd625726fc72e66afbd45b8d00 by Antoine Pitrou (Zackery Spytz) in branch 'master': bpo-24596: Decref module in PyRun_SimpleFileExFlags() on SystemExit (GH-7918) https://github.com/python/cpython/commit/d8cba5d16f1333fd625726fc72e66afbd45b8d00 | ||
msg321003 - (view) | Author: Antoine Pitrou (pitrou) * ![]() |
Date: 2018-07-03 20:13 |
New changeset 20ae4c60258479a0732d12af292f422679444e2c by Antoine Pitrou (Miss Islington (bot)) in branch '3.7': bpo-24596: Decref module in PyRun_SimpleFileExFlags() on SystemExit (GH-7918) (GH-8070) https://github.com/python/cpython/commit/20ae4c60258479a0732d12af292f422679444e2c | ||
msg321004 - (view) | Author: Antoine Pitrou (pitrou) * ![]() |
Date: 2018-07-03 20:17 |
New changeset e1ebf51f76037b7e02711aaeb9bf66c9147f4c74 by Antoine Pitrou (Miss Islington (bot)) in branch '3.6': bpo-24596: Decref module in PyRun_SimpleFileExFlags() on SystemExit (GH-7918) (GH-8069) https://github.com/python/cpython/commit/e1ebf51f76037b7e02711aaeb9bf66c9147f4c74 |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:58:18 | admin | set | github: 68784 |
2018-07-03 20🔞03 | pitrou | set | status: open -> closedresolution: fixedstage: patch review -> resolved |
2018-07-03 20:17:48 | pitrou | set | messages: + |
2018-07-03 20:13:32 | pitrou | set | messages: + |
2018-07-03 19:48:48 | miss-islington | set | pull_requests: + <pull%5Frequest7680> |
2018-07-03 19:48:01 | miss-islington | set | pull_requests: + <pull%5Frequest7679> |
2018-07-03 19:47:31 | pitrou | set | messages: + |
2018-06-25 23:02:52 | ZackerySpytz | set | nosy: + ZackerySpytzversions: + Python 3.7, Python 3.8, - Python 3.4, Python 3.5 |
2018-06-25 22:59:09 | ZackerySpytz | set | keywords: + patchstage: patch reviewpull_requests: + <pull%5Frequest7524> |
2015-07-09 14:10:29 | pitrou | set | nosy: + ncoghlanmessages: + |
2015-07-09 13:55:52 | pitrou | set | nosy: + pitroumessages: + |
2015-07-09 13:31:32 | petr.viktorin | create |