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
{{ message }}
Repository navigation
Warnings operate out of global runtime state. #80918
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='https://github.com/ericsnowcurrently'closed_at=<Date2019-05-10.17:30:26.460>created_at=<Date2019-04-26.22:28:58.200>labels= ['expert-subinterpreters', '3.8', 'type-bug', '3.7', '3.9']
title='Warnings operate out of global runtime state.'updated_at=<Date2020-05-15.00:37:35.654>user='https://github.com/ericsnowcurrently'
The warnings module's state (filters, default action, etc.) is currently stored at the level of the global runtime. That's a problem for the following reasons:
Python objects are getting stored in _PyRuntimeState
it breaks the isolation of behavior between interpreters
objects are leaking between interpreters
importing the module in a subinterpreter effectively resets the module's state
While those are all a problem in a future where interpreters don't share the GIL, that last one is a problem right now for people using subinterpreters.
I could also see use cases for *also* configuring warnings process-wide but that could be handled separately if actually desired.
Beyond "warning configuration is inherited by new interpreters", I don't see any reason to have process wide configuration. People using Python directly will get "process" wide from runtime configuration, and embedders don't want anything implicitly process-wide at all.
Also, the whole idea of inheriting things (settings, some copied objects, etc.) into subinterpreters is interesting. My initial reaction is that folks would appreciate that feature, at least for a handful of things. It's not critical, but is worth adding to the list of deferred ideas in PEP-554. :)
Activity
ericsnowcurrently commentedon Apr 26, 2019
(See Include/internal/pycore_warnings.h and Python/_warnings.c.)
The warnings module's state (filters, default action, etc.) is currently stored at the level of the global runtime. That's a problem for the following reasons:
While those are all a problem in a future where interpreters don't share the GIL, that last one is a problem right now for people using subinterpreters.
One of the following should happen:
I could also see use cases for *also* configuring warnings process-wide but that could be handled separately if actually desired.
zooba commentedon Apr 27, 2019
Beyond "warning configuration is inherited by new interpreters", I don't see any reason to have process wide configuration. People using Python directly will get "process" wide from runtime configuration, and embedders don't want anything implicitly process-wide at all.
ericsnowcurrently commentedon Apr 27, 2019
Good point.
Also, the whole idea of inheriting things (settings, some copied objects, etc.) into subinterpreters is interesting. My initial reaction is that folks would appreciate that feature, at least for a handful of things. It's not critical, but is worth adding to the list of deferred ideas in PEP-554. :)
ericsnowcurrently commentedon May 10, 2019
New changeset 86ea581 by Eric Snow in branch 'master':
bpo-36737: Use the module state C-API for warnings. (gh-13159)
86ea581