You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
assignee=Noneclosed_at=<Date2016-03-22.23:56:19.424>created_at=<Date2016-03-19.13:34:14.782>labels= ['type-feature']
title='_warnings.warn_explicit() should try to import the warnings module'updated_at=<Date2016-03-22.23:56:19.423>user='https://github.com/vstinner'
The issue bpo-26567 enhanced the warnings module to pass the destroyed object on ResourceWarning. The implementation to log the traceback where the object was allocated is non trivial, so I chose to only implement it in Python.
Problem: _warnings.warn_explicit() is lazy, it tries to get the warnings module from sys.modules, but it uses its own logger if the warnings is not imported yet.
As a consequence, the traceback where the object was allocated is only logged if tracemalloc is tracing Python memory allocations *and* if the warnings module is already imported.
I suggest to modify _warnings.warn_explicit() to import the warnings if it's not imported yet.
There are maybe issues to import a module during Python finalization? A comprise is to not try to import when Python finalization has started.
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: