A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2015-September/141733.html below:

[Python-Dev] Make stacklevel=2 by default in warnings.warn()

[Python-Dev] Make stacklevel=2 by default in warnings.warn() [Python-Dev] Make stacklevel=2 by default in warnings.warn()Gustavo Carneiro gjcarneiro at gmail.com
Sun Sep 20 12:27:00 CEST 2015
On 20 September 2015 at 07:55, Nathaniel Smith <njs at pobox.com> wrote:

> On Sat, Sep 19, 2015 at 11:44 PM, Serhiy Storchaka <storchaka at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20150920/54d9f022/attachment.html>
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4