New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Script globals in a GC cycle not finalized when exiting with SystemExit #68784
Comments
When this program is invoked as a script ( --- 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. |
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. |
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. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: