code: def _has_fileno(stream):
      
      try:
          stream.fileno()
      except (AttributeError, OSError, IOError, io.UnsupportedOperation):
          return False
      return True
docs: Returns whether the stream object seems to have a working fileno()
  
      Tells whether _redirect_stderr is likely to work.
  
      Parameters
      ----------
      stream : IO stream object
  
      Returns
      -------
      has_fileno : bool
          True if stream.fileno() exists and doesn't raise OSError or
          UnsupportedOperation