Package tdi :: Module _exceptions :: Class Warning
[frames] | no frames]

Class Warning

              object --+            
                       |            
exceptions.BaseException --+        
                           |        
        exceptions.Exception --+    
                               |    
              exceptions.Warning --+
                                   |
                                  Warning
Known Subclasses:

Base warning for this package

>>> with _warnings.catch_warnings(record=True) as record:
...     Warning.emit('my message')
...     assert len(record) == 1
...     str(record[0].message)
'my message'
>>> _warnings.simplefilter('error')
>>> Warning.emit('lalala')
Traceback (most recent call last):
...
Warning: lalala
Instance Methods

Inherited from exceptions.Warning: __init__, __new__

Inherited from exceptions.BaseException: __delattr__, __getattribute__, __getitem__, __getslice__, __reduce__, __repr__, __setattr__, __setstate__, __str__, __unicode__

Inherited from object: __format__, __hash__, __reduce_ex__, __sizeof__, __subclasshook__

Class Methods
 
emit(cls, message, stacklevel=1)
Emit a warning of this very category
Properties

Inherited from exceptions.BaseException: args, message

Inherited from object: __class__

Method Details

emit(cls, message, stacklevel=1)
Class Method

 

Emit a warning of this very category

This method is pure convenience. It saves you the unfriendly warnings.warn syntax (and the warnings import).

Parameters:
  • message (any) - The warning message
  • stacklevel (int) - Number of stackframes to go up in order to place the warning source. This is useful for generic warning-emitting helper functions. The stacklevel of this helper function is already taken into account.