cgi.catch_warnings

class cgi.catch_warnings(record=False, module=None)[source]

A context manager that copies and restores the warnings filter upon exiting the context.

The ‘record’ argument specifies whether warnings should be captured by a custom implementation of warnings.showwarning() and be appended to a list returned by the context manager. Otherwise None is returned by the context manager. The objects appended to the list are arguments whose attributes mirror the arguments to showwarning().

The ‘module’ argument is to specify an alternative module to the module named ‘warnings’ and imported under that name. This argument is only useful when testing the warnings module itself.

Methods

__enter__()
__exit__(*exc_info)
__format__ default object formatter
__init__([record, module]) Specify whether to record warnings and if an alternative module should be used other than sys.modules[‘warnings’].
__new__((S, ...)
__reduce__ helper for pickle
__reduce_ex__ helper for pickle
__repr__()
__sizeof__(() -> int) size of object in memory, in bytes
__subclasshook__ Abstract classes can override this to customize issubclass().