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
no way to introspect registered atexit handlers #61388
Comments
Python 2 had a private but usable way of introspecting and manipulating registered atexit handlers by way of the atexit._exithandlers. In Python 3, registering and unregistering are handled, but there is no longer a way to see what atexit handlers are registered. Barry suggested filing a bug to have this added as a new feature for Python 3.4. Some kind of read-only sequence would be fine, if the original list can no longer be exposed. |
Could you please give an example of why this would be a useful addition? |
Barry advised me to open this issue as it's a functional regression from Python 2. My use case is unit testing code that registers atexit handlers and making sure the right handlers are registered with the correct parameters. |
But it was relying on a private and non documented feature in Python
IMO, complicating an API for testing purpose is a bad idea. |
I can think of other use cases. Anyway, I'm just glad your opinion isn't the only one there is ;-) |
I don't think you want your test suite to run your atexit handlers at exit, so you should probably mock atexit.register instead. |
On Feb 22, 2013, at 06:54 PM, Charles-François Natali wrote:
I also suggested it would have to be considered a new feature for 3.4. |
See also bpo-32082. |
A hacky way to see which handlers are registered is discussed here: https://stackoverflow.com/a/63029332/1250282. |
It's sad that this hack is needed, I really do think there should be a way to introspect what exit handler are currently registered. New feature or regression from 2.7, either way, it would be great to have this functionality given the set of folks that want it. |
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: