cpython
cpython copied to clipboard
warnings in interactive sessions
BPO | 1539925 |
---|---|
Nosy | @malemburg, @birkenfeld, @ncoghlan, @vadmium, @serhiy-storchaka |
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 = None
closed_at = None
created_at = <Date 2006-08-14.11:03:41.000>
labels = ['3.7', 'type-feature', 'library']
title = 'warnings in interactive sessions'
updated_at = <Date 2017-11-14.01:01:29.867>
user = 'https://github.com/malemburg'
bugs.python.org fields:
activity = <Date 2017-11-14.01:01:29.867>
actor = 'ncoghlan'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2006-08-14.11:03:41.000>
creator = 'lemburg'
dependencies = []
files = []
hgrepos = []
issue_num = 1539925
keywords = []
message_count = 5.0
messages = ['60969', '85079', '199793', '306141', '306180']
nosy_count = 6.0
nosy_names = ['lemburg', 'georg.brandl', 'ncoghlan', 'martin.panter', 'serhiy.storchaka', 'Alan.Cristhian']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'needs patch'
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue1539925'
versions = ['Python 3.7']
Carried over from Patch bpo-1538956 description:
During testing I found that the warning registry defaults to only issueing warnings once per module and line number.
I suppose this is enough for debugging code, but it feels weird when trying things in the interactive session, as you only get the warnings once in that context (and for the whole session), regardless of the fact that you're entering new lines of code all the time.
The reason is that the warning framework registers warnings based on line number which usually is 1 in interactive sessions.
In general, it might be a better idea to have a single global warning registry and then include the module name or id in the registry key. Currently, the warning framework creates a new registry per (module) context.
Not a bad idea, although it would require some work to make it work in a backwards-compatible fashion.
Is there still any interest in this?
Looks reasonable to me. Perhaps we should port the solution from IPython: https://github.com/ipython/ipython/issues/6611.
As a user, what would I actually gain from being warned more than once per session that a particular API I'm using is deprecated?
If I want that behaviour, I can already opt in to it by doing "warnings.simplefilter('always')".
As things stand, the perpetually reset line counter just means that the effective default at the REPL is "warnings.simplefilter('module:::main')"