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

Nathaniel Smith njs at pobox.com
Tue Sep 22 00:29:52 CEST 2015


On Mon, Sep 21, 2015 at 10:14 AM, Serhiy Storchaka <storchaka at gmail.com> wrote:

stacklevel=2 is correct argument for module level warnings, but as Nathaniel noted not all packages use it. When your run correctly written module as script you get the same "sys:1:". And this issue can be solved in general case.

Point of information: for module deprecations, stacklevel=2 is correct in 2.7 and 3.5, but in 3.4 the correct value is stacklevel=8 (see https://bugs.python.org/issue24305#msg249981). I'm inclined to think that this is a bug that should be fixed in 3.4.4, but Larry disagrees and I don't really care enough to argue about it either way :-).

-n

-- Nathaniel J. Smith -- http://vorpus.org



More information about the Python-Dev mailing list