cpython icon indicating copy to clipboard operation
cpython copied to clipboard

warnings in interactive sessions

Open malemburg opened this issue 18 years ago • 5 comments

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']

malemburg avatar Aug 14 '06 11:08 malemburg

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.

malemburg avatar Aug 14 '06 11:08 malemburg

Not a bad idea, although it would require some work to make it work in a backwards-compatible fashion.

brettcannon avatar Apr 01 '09 19:04 brettcannon

Is there still any interest in this?

birkenfeld avatar Oct 13 '13 20:10 birkenfeld

Looks reasonable to me. Perhaps we should port the solution from IPython: https://github.com/ipython/ipython/issues/6611.

serhiy-storchaka avatar Nov 13 '17 05:11 serhiy-storchaka

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')"

ncoghlan avatar Nov 14 '17 01:11 ncoghlan