class_docstr: 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.
  
  Notes
  -----
  `WarningManager` is a copy of the ``catch_warnings`` context manager
  from the Python 2.6 warnings module, with slight modifications.
  It is copied so it can be used in NumPy with older Python versions.
code: def __enter__(self):
      if self._entered:
          raise RuntimeError("Cannot enter %r twice" % self)
      self._entered = True
      self._filters = self._module.filters
      self._module.filters = self._filters[:]
      self._showwarning = self._module.showwarning
      if self._record:
          log = []
  
          def showwarning(*args, **kwargs):
              log.append(WarningMessage(*args, **kwargs))
  
          self._module.showwarning = showwarning
          return log
      else:
          return None
  
file_path: catboost/contrib/python/ipython/py2/IPython/external/decorators/_numpy_testing_utils.py
imports: import sys
  import warnings
label_desc: Use image node_id 2 for calling the WarningManager obj's underlying member method code with example usage: obj.__enter__() and returns: log, None