parameters: (message, category=None, stacklevel=1, source=None)
docstring: Issue a warning, or maybe ignore it or raise an exception.
docstring_summary: Issue a warning, or maybe ignore it or raise an exception.
docstring_tokens: Issue a warning or maybe ignore it or raise an exception .
function: def warn(message, category=None, stacklevel=1, source=None):
      """Issue a warning, or maybe ignore it or raise an exception."""
      # Check if message is already a Warning object
      if isinstance(message, Warning):
          category = message.__class__
      # Check category argument
      if category is None:
          category = UserWarning
      if not (isinstance(category, type) and issubclass(category, Warning)):
          raise TypeError("category must be a Warning subclass, "
                          "not '{:s}'".format(type(category).__name__))
      # Get context information
      try:
          if stacklevel <= 1 or _is_internal_frame(sys._getframe(1)):
              # If frame is too small to care or if the warning originated in
              # internal code, then do not try to hide any frames.
              frame = sys._getframe(stacklevel)
          else:
              frame = sys._getframe(1)
              # Look for one frame less since the above line starts us off.
              for x in range(stacklevel-1):
                  frame = _next_external_frame(frame)
                  if frame is None:
                      raise ValueError
      except ValueError:
          globals = sys.__dict__
          lineno = 1
      else:
          globals = frame.f_globals
          lineno = frame.f_lineno
      if '__name__' in globals:
          module = globals['__name__']
      else:
          module = "<string>"
      filename = globals.get('__file__')
      if filename:
          fnl = filename.lower()
          if fnl.endswith(".pyc"):
              filename = filename[:-1]
      else:
          if module == "__main__":
              try:
                  filename = sys.argv[0]
              except AttributeError:
                  # embedded interpreters don't have sys.argv, see bug #839151
                  filename = '__main__'
          if not filename:
              filename = module
      registry = globals.setdefault("__warningregistry__", {})
      warn_explicit(message, category, filename, lineno, module, registry,
                    globals, source)
function_tokens: def warn ( message , category = None , stacklevel = 1 , source = None ) : # Check if message is already a Warning object if isinstance ( message , Warning ) : category = message . __class__ # Check category argument if category is None : category = UserWarning if not ( isinstance ( category , type ) and issubclass ( category , Warning ) ) : raise TypeError ( "category must be a Warning subclass, " "not '{:s}'" . format ( type ( category ) . __name__ ) ) # Get context information try : if stacklevel <= 1 or _is_internal_frame ( sys . _getframe ( 1 ) ) : # If frame is too small to care or if the warning originated in # internal code, then do not try to hide any frames. frame = sys . _getframe ( stacklevel ) else : frame = sys . _getframe ( 1 ) # Look for one frame less since the above line starts us off. for x in range ( stacklevel - 1 ) : frame = _next_external_frame ( frame ) if frame is None : raise ValueError except ValueError : globals = sys . __dict__ lineno = 1 else : globals = frame . f_globals lineno = frame . f_lineno if '__name__' in globals : module = globals [ '__name__' ] else : module = "<string>" filename = globals . get ( '__file__' ) if filename : fnl = filename . lower ( ) if fnl . endswith ( ".pyc" ) : filename = filename [ : - 1 ] else : if module == "__main__" : try : filename = sys . argv [ 0 ] except AttributeError : # embedded interpreters don't have sys.argv, see bug #839151 filename = '__main__' if not filename : filename = module registry = globals . setdefault ( "__warningregistry__" , { } ) warn_explicit ( message , category , filename , lineno , module , registry , globals , source )