##// END OF EJS Templates
Reset the interactive namespace __warningregistry__ before executing code...
Reset the interactive namespace __warningregistry__ before executing code Fixes #6611. Idea: Right now, people often don't see important warnings when running code in IPython, because (to a first approximation) any given warning will only issue once per session. Blink and you'll miss it! This is a very common contributor to confused emails to numpy-discussion. E.g.: In [5]: 1 / my_array_with_random_contents /home/njs/.user-python2.7-64bit-3/bin/ipython:1: RuntimeWarning: divide by zero encountered in divide #!/home/njs/.user-python2.7-64bit-3/bin/python Out[5]: array([ 1.77073316, -2.29765021, -2.01800811, ..., 1.13871243, -1.08302964, -8.6185091 ]) Oo, right, guess I gotta be careful of those zeros -- thanks, numpy, for giving me that warning! A few days later: In [592]: 1 / some_other_array Out[592]: array([ 3.07735763, 0.50769289, 0.83984078, ..., -0.67563917, -0.85736257, -1.36511271]) Oops, it turns out that this array had a zero in it too, and that's going to bite me later. But no warning this time! The effect of this commit is to make it so that warnings triggered by the code in cell 5 do *not* suppress warnings triggered by the code in cell 592. Note that this only applies to warnings triggered *directly* by code entered interactively -- if somepkg.foo() calls anotherpkg.bad_func() which issues a warning, then this warning will still only be displayed once, even if multiple cells call somepkg.foo(). But if cell 5 and cell 592 both call anotherpkg.bad_func() directly, then both will get warnings. (Important exception: if foo() is defined *interactively*, and calls anotherpkg.bad_func(), then every cell that calls foo() will display the warning again. This is unavoidable without fixes to CPython upstream.) Explanation: Python's warning system has some weird quirks. By default, it tries to suppress duplicate warnings, where "duplicate" means the same warning message triggered twice by the same line of code. This requires determining which line of code is responsible for triggering a warning, and this is controlled by the stacklevel= argument to warnings.warn. Basically, though, the idea is that if foo() calls bar() which calls baz() which calls some_deprecated_api(), then baz() will get counted as being "responsible", and the warning system will make a note that the usage of some_deprecated_api() inside baz() has already been warned about and doesn't need to be warned about again. So far so good. To accomplish this, obviously, there has to be a record of somewhere which line this was. You might think that this would be done by recording the filename:linenumber pair in a dict inside the warnings module, or something like that. You would be wrong. What actually happens is that the warnings module will use stack introspection to reach into baz()'s execution environment, create a global (module-level) variable there named __warningregistry__, and then, inside this dictionary, record just the line number. Basically, it assumes that any given module contains only one line 1, only one line 2, etc., so storing the filename is irrelevant. Obviously for interactive code this is totally wrong -- all cells share the same execution environment and global namespace, and they all contain a new line 1. Currently the warnings module treats these as if they were all the same line. In fact they are not the same line; once we have executed a given chunk of code, we will never see those particular lines again. As soon as a given chunk of code finishes executing, its line number labels become meaningless, and the corresponding warning registry entries become meaningless as well. Therefore, with this patch we delete the __warningregistry__ each time we execute a new block of code.

File last commit:

r17930:7799fea5
r18548:61431d7d
Show More
.mailmap
133 lines | 9.4 KiB | text/plain | TextLexer
Aaron Culich <aculich@gmail.com> Aaron Culich <aculich@eecs.berkeley.edu>
Aron Ahmadia <aron@ahmadia.net> ahmadia <aron@ahmadia.net>
Benjamin Ragan-Kelley <benjaminrk@gmail.com> <minrk@Mercury.local>
Benjamin Ragan-Kelley <benjaminrk@gmail.com> Min RK
Benjamin Ragan-Kelley <benjaminrk@gmail.com> MinRK <benjaminrk@gmail.com>
Barry Wark <barrywark@gmail.com> Barry Wark <barrywarkatgmaildotcom>
Ben Edwards <bedwards@cs.unm.edu> Ben Edwards <bedwards@sausage.(none)>
Bradley M. Froehle <brad.froehle@gmail.com> Bradley M. Froehle <bfroehle@math.berkeley.edu>
Bradley M. Froehle <brad.froehle@gmail.com> Bradley Froehle <brad.froehle@gmail.com>
Brandon Parsons <brandon@parsonstx.com> Brandon Parsons <brandon.parsons@hp.com>
Brian E. Granger <ellisonbg@gmail.com> Brian Granger
Brian E. Granger <ellisonbg@gmail.com> Brian Granger <>
Brian E. Granger <ellisonbg@gmail.com> bgranger <>
Brian E. Granger <ellisonbg@gmail.com> bgranger <bgranger@red>
Christoph Gohlke <cgohlke@uci.edu> cgohlke <cgohlke@uci.edu>
Cyrille Rossant <cyrille.rossant@gmail.com> rossant <rossant@github>
Damián Avila <damianavila82@yahoo.com.ar> damianavila <damianavila82@yahoo.com.ar>
Damián Avila <damianavila82@yahoo.com.ar> damianavila <damianavila@gmail.com>
Darren Dale <dsdale24@gmail.com> darren.dale <>
Darren Dale <dsdale24@gmail.com> Darren Dale <>
Dav Clark <davclark@berkeley.edu> Dav Clark <>
Dav Clark <davclark@berkeley.edu> Dav Clark <davclark@gmail.com>
David Hirschfeld <david.hirschfeld@gazprom-mt.com> dhirschfeld <david.hirschfeld@gazprom-mt.com>
David P. Sanders <dpsanders@gmail.com> David P. Sanders <dpsanders@ciencias.unam.mx>
David Warde-Farley <wardefar@iro.umontreal.ca> David Warde-Farley <>
Doug Blank <dblank@cs.brynmawr.edu> Doug Blank <doug.blank@gmail.com>
Eugene Van den Bulke <eugene.van-den-bulke@gmail.com> Eugene Van den Bulke <eugene.vandenbulke@gmail.com>
Evan Patterson <epatters@enthought.com> <epatters@EPattersons-MacBook-Pro.local>
Evan Patterson <epatters@enthought.com> <epatters@evan-laptop.localdomain>
Evan Patterson <epatters@enthought.com> <epatters@caltech.edu>
Evan Patterson <epatters@enthought.com> <ejpatters@gmail.com>
Evan Patterson <epatters@enthought.com> epatters <ejpatters@gmail.com>
Evan Patterson <epatters@enthought.com> epatters <epatters@enthought.com>
Ernie French <ernestfrench@gmail.com> Ernie French <ernie@gqpbj.com>
Ernie French <ernestfrench@gmail.com> ernie french <ernestfrench@gmail.com>
Ernie French <ernestfrench@gmail.com> ernop <ernestfrench@gmail.com>
Fernando Perez <Fernando.Perez@berkeley.edu> <fperez.net@gmail.com>
Fernando Perez <Fernando.Perez@berkeley.edu> Fernando Perez <fernando.perez@berkeley.edu>
Fernando Perez <Fernando.Perez@berkeley.edu> fperez <>
Fernando Perez <Fernando.Perez@berkeley.edu> fptest <>
Fernando Perez <Fernando.Perez@berkeley.edu> fptest1 <>
Fernando Perez <Fernando.Perez@berkeley.edu> Fernando Perez <fernando.perez@berkeley.edu>
Fernando Perez <fernando.perez@berkeley.edu> Fernando Perez <>
Fernando Perez <fernando.perez@berkeley.edu> Fernando Perez <fperez@maqroll>
Frank Murphy <fpmurphy@mtu.edu> Frank Murphy <fmurphy@arbor.net>
Gabriel Becker <gmbecker@ucdavis.edu> gmbecker <gmbecker@ucdavis.edu>
Gael Varoquaux <gael.varoquaux@normalesup.org> gael.varoquaux <>
Gael Varoquaux <gael.varoquaux@normalesup.org> gvaroquaux <gvaroquaux@gvaroquaux-desktop>
Gael Varoquaux <gael.varoquaux@normalesup.org> Gael Varoquaux <>
Ingolf Becker <ingolf.becker@googlemail.com> watercrossing <ingolf.becker@googlemail.com>
Jake Vanderplas <jakevdp@gmail.com> Jake Vanderplas <vanderplas@astro.washington.edu>
Jakob Gager <jakob.gager@gmail.com> jakobgager <jakob.gager@gmail.com>
Jakob Gager <jakob.gager@gmail.com> jakobgager <gager@ilsb.tuwien.ac.at>
Jakob Gager <jakob.gager@gmail.com> jakobgager <jakobgager@hotmail.com>
Jason Grout <jgrout6@bloomberg.net> <jason.grout@drake.edu>
Jason Grout <jgrout6@bloomberg.net> <jason-github@creativetrax.com>
Jens Hedegaard Nielsen <jenshnielsen@gmail.com> Jens Hedegaard Nielsen <jhn@jhn-Znote.(none)>
Jens Hedegaard Nielsen <jenshnielsen@gmail.com> Jens H Nielsen <jenshnielsen@gmail.com>
Jens Hedegaard Nielsen <jenshnielsen@gmail.com> Jens H. Nielsen <jenshnielsen@gmail.com>
Jez Ng <jezreel@gmail.com> Jez Ng <me@jezng.com>
Jonathan Frederic <jdfreder@calpoly.edu> Jonathan Frederic <jonathan@LifebookMint.(none)>
Jonathan Frederic <jdfreder@calpoly.edu> Jonathan Frederic <jon.freder@gmail.com>
Jonathan Frederic <jdfreder@calpoly.edu> Jonathan Frederic <xh3xx.goose@gmail.com>
Jonathan Frederic <jdfreder@calpoly.edu> jon <jon.freder@gmail.com>
Jonathan March <jmarch@enthought.com> Jonathan March <JDM@MarchRay.net>
Jonathan March <jmarch@enthought.com> jdmarch <JDM@marchRay.net>
Jörgen Stenarson <jorgen.stenarson@kroywen.se> Jörgen Stenarson <jorgen.stenarson@bostream.nu>
Jörgen Stenarson <jorgen.stenarson@kroywen.se> Jorgen Stenarson <jorgen.stenarson@bostream.nu>
Jörgen Stenarson <jorgen.stenarson@kroywen.se> Jorgen Stenarson <>
Jörgen Stenarson <jorgen.stenarson@kroywen.se> jstenar <jorgen.stenarson@bostream.nu>
Jörgen Stenarson <jorgen.stenarson@kroywen.se> jstenar <>
Jörgen Stenarson <jorgen.stenarson@kroywen.se> Jörgen Stenarson <jorgen.stenarson@kroywen.se>
Juergen Hasch <python@elbonia.de> juhasch <python@elbonia.de>
Kyle Kelley <rgbkrk@gmail.com> Kyle Kelley <kyle.kelley@rackspace.com>
Laurent Dufréchou <laurent.dufrechou@gmail.com> <laurent.dufrechou@gmail.com>
Laurent Dufréchou <laurent.dufrechou@gmail.com> <laurent@Pep>
Laurent Dufréchou <laurent.dufrechou@gmail.com> laurent dufrechou <>
Laurent Dufréchou <laurent.dufrechou@gmail.com> laurent.dufrechou <>
Laurent Dufréchou <laurent.dufrechou@gmail.com> Laurent Dufrechou <>
Laurent Dufréchou <laurent.dufrechou@gmail.com> laurent.dufrechou@gmail.com <>
Laurent Dufréchou <laurent.dufrechou@gmail.com> ldufrechou <ldufrechou@PEP>
Luis Pedro Coelho <luis@luispedro.org> Luis Pedro Coelho <lpc@cmu.edu>
Marc Molla <marcmolla@gmail.com> marcmolla <marcmolla@gmail.com>
Martín Gaitán <gaitan@gmail.com> Martín Gaitán <gaitan@phasety.com>
Matthias Bussonnier <bussonniermatthias@gmail.com> Matthias BUSSONNIER <bussonniermatthias@gmail.com>
Matthias Bussonnier <bussonniermatthias@gmail.com> Bussonnier Matthias <bussonniermatthias@gmail.com>
Matthias Bussonnier <bussonniermatthias@gmail.com> Matthias BUSSONNIER <bussonniermatthias@umr168-curn-1-24x-6561.curie.fr>
Matthias Bussonnier <bussonniermatthias@gmail.com> Matthias Bussonnier <carreau@Aspire.(none)>
Michael Droettboom <mdboom@gmail.com> Michael Droettboom <mdroe@stsci.edu>
Nicolas Rougier <Nicolas.Rougier@inria.fr> <Nicolas.rougier@inria.fr>
Omar Andrés Zapata Mesa <andresete.chaos@gmail.com> Omar Andres Zapata Mesa <andresete.chaos@gmail.com>
Omar Andrés Zapata Mesa <andresete.chaos@gmail.com> Omar Andres Zapata Mesa <omazapa@tuxhome>
Pankaj Pandey <pankaj86@gmail.com> Pankaj Pandey <pankaj@enthought.com>
Pascal Schetelat <pascal.schetelat@gmail.com> pascal-schetelat <pascal.schetelat@gmail.com>
Paul Ivanov <pi@berkeley.edu> Paul Ivanov <pivanov314@gmail.com>
Pauli Virtanen <pauli.virtanen@iki.fi> Pauli Virtanen <>
Pauli Virtanen <pauli.virtanen@iki.fi> Pauli Virtanen <pav@iki.fi>
Pietro Berkes <pberkes@enthought.com> Pietro Berkes <pietro.berkes@googlemail.com>
Piti Ongmongkolkul <piti118@gmail.com> piti118 <piti118@gmail.com>
Prabhu Ramachandran <prabhu@enthought.com> Prabhu Ramachandran <>
Puneeth Chaganti <punchagan@gmail.com> Puneeth Chaganti <punchagan@muse-amuse.in>
Robert Kern <robert.kern@gmail.com> rkern <>
Robert Kern <robert.kern@gmail.com> Robert Kern <rkern@enthought.com>
Robert Kern <robert.kern@gmail.com> Robert Kern <rkern@Sacrilege.local>
Robert Kern <robert.kern@gmail.com> Robert Kern <>
Robert Marchman <bo.marchman@gmail.com> Robert Marchman <robert.l.marchman@dartmouth.edu>
Satrajit Ghosh <satra@mit.edu> Satrajit Ghosh <satra@ba5.mit.edu>
Satrajit Ghosh <satra@mit.edu> Satrajit Ghosh <satrajit.ghosh@gmail.com>
smithj1 <smithj1@LMC-022896.local> smithj1 <smithj1@LMC-022896.swisscom.com>
smithj1 <smithj1@LMC-022896.local> smithj1 <smithj1@lmc-022896.local>
Steven Johnson <steven.johnson@drake.edu> stevenJohnson <steven.johnson@drake.edu>
Steven Silvester <steven.silvester@ieee.org> blink1073 <steven.silvester@ieee.org>
S. Weber <s8weber@c4.usr.sh> s8weber <s8weber@c5.usr.sh>
Stefan van der Walt <stefan@sun.ac.za> Stefan van der Walt <bzr@mentat.za.net>
Sylvain Corlay <scorlay@bloomberg.net> <sylvain.corlay@gmail.com>
Sylvain Corlay <scorlay@bloomberg.net> sylvain.corlay <sylvain.corlay@gmail.com>
Ted Drain <ted.drain@gmail.com> TD22057 <ted.drain@gmail.com>
Théophile Studer <theo.studer@gmail.com> Théophile Studer <studer@users.noreply.github.com>
Thomas Kluyver <takowl@gmail.com> Thomas <takowl@gmail.com>
Thomas Spura <tomspur@fedoraproject.org> Thomas Spura <thomas.spura@gmail.com>
Timo Paulssen <timonator@perpetuum-immobile.de> timo <timonator@perpetuum-immobile.de>
vds <vds@VIVIAN> vds2212 <vds2212@VIVIAN>
vds <vds@VIVIAN> vds <vds@vivian>
Ville M. Vainio <vivainio@gmail.com> <vivainio2@WN-W0941>
Ville M. Vainio <vivainio@gmail.com> ville <ville@VILLE-PC>
Ville M. Vainio <vivainio@gmail.com> ville <ville@ville-desktop>
Ville M. Vainio <vivainio@gmail.com> vivainio <>
Ville M. Vainio <vivainio@gmail.com> Ville M. Vainio <vivainio@villev>
Ville M. Vainio <vivainio@gmail.com> Ville M. Vainio <vivainio@ville_vmw>
Walter Doerwald <walter@livinglogic.de> walter.doerwald <>
Walter Doerwald <walter@livinglogic.de> Walter Doerwald <>
W. Trevor King <wking@tremily.us> W. Trevor King <wking@drexel.edu>
Yoval P. <yoval@gmx.com> y-p <yoval@gmx.com>