I'm trying to raise a DeprecationWarning
, with a code snippet based on the example shown in the docs. http://docs.python.org/2/library/warnings.html#warnings.warn
Official
def deprecation(message):
warnings.warn(message, DeprecationWarning, stacklevel=2)
Mine
import warnings
warnings.warn("This is a warnings.", DeprecationWarning, stacklevel=2) is None # returns True
I've tried removing the stacklevel argument, setting it to negative, 0, 2 and 20000. The warning is always silently swallowed. It doesn't issue a warning or raise an exception. It just ignores the line and returns None
. The docs doesn't mention the criteria for ignoring. Giving a message, makes warnings.warn correctly issue a Userwarning.
What can be causing this and how do I get warn to actually warn?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…