Author njs
Recipients Arfrever, barry, berker.peksag, brett.cannon, eric.snow, josh.r, jwilk, larry, ncoghlan, njs, serhiy.storchaka, takluyver
Date 2015-08-25.00:36:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1440462980.18.0.39748135899.issue24305@psf.upfronthosting.co.za>
In-reply-to
Content
> I still don't quite understand: what is the user-perceived result of this change?  Module authors issuing a DeprecationWarning can now use stacklevel=2 instead of stacklevel=10?

Exactly. There are a lot of deprecated modules in the wild, and the correct way to mark a module as deprecated is by writing

warnings.warn("This module is deprecated!", stacklevel=2)

at the top-level of your module. Except that in Python 3.3 you have to use stacklevel=10, and in Python 3.4 you have to use stacklevel=8, and I haven't checked what you need in Python 3.5 but it may well be different again, because it depends on internal implementation details of the import system. Fortunately AFAICT from some code searches no-one is actually depending on this though; instead everyone just writes stacklevel=2 and gets the wrong result.

(This is made more urgent b/c people are increasingly relying on the stacklevel information to filter whether they even see the DeprecationWarning. E.g. I've seen multiple test suites which register a warnings filter that displays DeprecationWarnings iff they are attributed to the package-under-test, and IPython now shows deprecation warnings by default if the warning is attributed to interactive code -- see issue 24294. So there's a good chance that users will only find out that the module they are using is deprecated if the stacklevel= is set correctly.)
History
Date User Action Args
2015-08-25 00:36:20njssetrecipients: + njs, barry, brett.cannon, ncoghlan, larry, jwilk, Arfrever, eric.snow, takluyver, berker.peksag, serhiy.storchaka, josh.r
2015-08-25 00:36:20njssetmessageid: <1440462980.18.0.39748135899.issue24305@psf.upfronthosting.co.za>
2015-08-25 00:36:20njslinkissue24305 messages
2015-08-25 00:36:18njscreate