Message250975
| Author |
Arfrever |
| Recipients |
Arfrever, benjamin.peterson, brett.cannon, larry, python-dev, serhiy.storchaka, terry.reedy |
| Date |
2015年09月18日.13:06:09 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1442581570.38.0.656183815597.issue24199@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
> 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)
$ |
|