(capture)
Replace warning.showwarning with idle_showwarning, or reverse.
Replace warning.showwarning with idle_showwarning, or reverse.
Replace warning . showwarning with idle_showwarning or reverse .
def capture_warnings(capture):
    "Replace warning.showwarning with idle_showwarning, or reverse."

    global _warnings_showwarning
    if capture:
        if _warnings_showwarning is None:
            _warnings_showwarning = warnings.showwarning
            warnings.showwarning = idle_showwarning
    else:
        if _warnings_showwarning is not None:
            warnings.showwarning = _warnings_showwarning
            _warnings_showwarning = None
def capture_warnings ( capture ) : global _warnings_showwarning if capture : if _warnings_showwarning is None : _warnings_showwarning = warnings . showwarning warnings . showwarning = idle_showwarning else : if _warnings_showwarning is not None : warnings . showwarning = _warnings_showwarning _warnings_showwarning = None