On 20 September 2015 at 07:55, Nathaniel Smith <n...@pobox.com> wrote:
> On Sat, Sep 19, 2015 at 11:44 PM, Serhiy Storchaka <storch...@gmail.com> > wrote: > > For now the default value of the stacklevel parameter in warnings.warn() > is > > 1. But in most cases stacklevel=2 is required, sometimes >2, and I don't > > know cases that need stacklevel=1. I propose to make the default value of > > stacklevel to be 2. I think that unlikely this will break existing code. > But > > rather can fix existing bugs. If stacklevel=1 is required (I don't know > > cases), it can be explicitly specified. > > +1 > > I don't have enough fingers to count how many times I've had to > explain how stacklevel= works to maintainers of widely-used packages > -- they had no idea that this was even a thing they were getting > wrong. > > OTOH I guess if there is anyone out there who's intentionally using > stacklevel=1 they might be reasonably surprised at this change. I > guess for some kinds of warnings stacklevel=2 is not obviously correct > -- the one that comes to mind is "warning: the computer on the other > end of this network connection did something weird, continuing > anyway". OTOOH in this case I'm not sure stacklevel=1 is any better > either, since the thing being warned about has nothing to do with the > current call stack at all. > In this case you should use the logging module instead. -- Gustavo J. A. M. Carneiro Gambit Research "The universe is always one step beyond logic." -- Frank Herbert
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com