Issue 1539925: warnings in interactive sessions

Issue1539925

Created on 2006-08-14 11:03 by lemburg, last changed 2022-04-11 14:56 by admin.

Messages (5)
msg60969 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2006-08-14 11:03
Carried over from Patch #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.
msg85079 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2009-04-01 19:14
Not a bad idea, although it would require some work to make it work in a
backwards-compatible fashion.
msg199793 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2013-10-13 20:26
Is there still any interest in this?
msg306141 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-11-13 05:50
Looks reasonable to me. Perhaps we should port the solution from IPython:
https://github.com/ipython/ipython/issues/6611.
msg306180 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2017-11-14 01:01
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__')"
History
Date User Action Args
2022-04-11 14:56:19adminsetgithub: 43816
2017-11-14 01:01:29ncoghlansetnosy: + ncoghlan
messages: + msg306180
2017-11-13 05:50:14serhiy.storchakasetmessages: + msg306141
versions: + Python 3.7, - Python 3.5
2015-02-26 21:07:12martin.pantersetnosy: + martin.panter
2015-02-26 13:00:33serhiy.storchakasetnosy: + serhiy.storchaka

versions: + Python 3.5, - Python 3.4

2013-10-13 22:15:25Alan.Cristhiansetnosy: + Alan.Cristhian
2013-10-13 20:26:53georg.brandlsetnosy: + georg.brandl
messages: + msg199793
2012-11-18 19:28:32ezio.melottisetstage: needs patch
versions: + Python 3.4, - Python 3.2
2012-11-17 17:12:57brett.cannonsetnosy: - brett.cannon
2010-07-10 06:28:52terry.reedysetversions: + Python 3.2, - Python 2.6
2009-04-01 19:14:14brett.cannonsetassignee: brett.cannon ->
messages: + msg85079
2009-02-11 03:08:20ajaksu2setassignee: brett.cannon
type: enhancement
nosy: + brett.cannon
2006-08-14 11:03:41lemburgcreate