homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: DeprecationWarning hidden even after warnings.filterwarnings('always') called
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: warnings.simplefilter("always") does not make warnings always show up
View: 4180
Assigned To: Nosy List: abukaj, ned.deily
Priority: normal Keywords:

Created on 2015年06月23日 14:12 by abukaj, last changed 2022年04月11日 14:58 by admin. This issue is now closed.

Messages (2)
msg245691 - (view) Author: Jakub Mateusz Dzik (abukaj) Date: 2015年06月23日 14:12
The error occurs when there was a warning before the call to filterwarnings():
$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import warnings
>>> warnings.warn('aa', DeprecationWarning)
>>> warnings.filterwarnings('always')
>>> warnings.warn('aa', DeprecationWarning)
>>>
When filterwarnings() is called before warnings, everything is working as expected:
$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import warnings
>>> warnings.filterwarnings('always')
>>> warnings.warn('aa', DeprecationWarning)
__main__:1: DeprecationWarning: aa
>>> warnings.warn('aa', DeprecationWarning)
__main__:1: DeprecationWarning: aa
>>>
msg245708 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2015年06月24日 03:32
The problem you describe was covered by Issue4180 and fixed in Python 3.4.2. From the discussion there, you can see that it was decided to not change the behavior of Python 2.7.
History
Date User Action Args
2022年04月11日 14:58:18adminsetgithub: 68678
2015年06月24日 03:32:35ned.deilysetstatus: open -> closed

superseder: warnings.simplefilter("always") does not make warnings always show up

nosy: + ned.deily
messages: + msg245708
resolution: duplicate
stage: resolved
2015年06月23日 14:12:09abukajcreate

AltStyle によって変換されたページ (->オリジナル) /