Message250975
> Since I am not wrapping the warning, the default stacklevel seems to work on all versions.
The purpose of stacklevel=2 here would be to make warning message indicate which file contains import of deprecated module.
See below example, which shows that stacklevel=2 in formatter.py and imp.py results in message pointing to bbb.py as containing imports of deprecated modules:
$ cat aaa.py
import bbb
$ cat bbb.py
import formatter
import imp
import idlelib.idlever
$ python3.5 -Wd -c 'import aaa'
/tmp/bbb.py:1: DeprecationWarning: the formatter module is deprecated and will be removed in Python 3.6
import formatter
/tmp/bbb.py:2: PendingDeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
/usr/lib64/python3.5/idlelib/idlever.py:10: DeprecationWarning:
The separate Idle version was eliminated years ago;
idlelib.idlever is no longer used by Idle
and will be removed in 3.6 or later. Use
from sys import version
IDLE_VERSION = version[:version.index(' ')]
w.warn(__doc__, DeprecationWarning)
$ |
|
Date |
User |
Action |
Args |
2015-09-18 13:06:10 | Arfrever | set | recipients:
+ Arfrever, brett.cannon, terry.reedy, larry, benjamin.peterson, python-dev, serhiy.storchaka |
2015-09-18 13:06:10 | Arfrever | set | messageid: <1442581570.38.0.656183815597.issue24199@psf.upfronthosting.co.za> |
2015-09-18 13:06:10 | Arfrever | link | issue24199 messages |
2015-09-18 13:06:09 | Arfrever | create | |
|