code: def wrap_file_exceptions():
      
      try:
          yield
      except (PermissionError, FileNotFoundError):  # pragma: only py3
          # In py3, we want to raise Exception unchanged, so there would be no need for this block.
          # BUT (IOError, OSError) - see below - also matches, so we capture it here
          raise
      except (IOError, OSError) as e:  # pragma: only py2
          if e.errno == errno.EACCES:
              raise PermissionError(str(e))
          elif e.errno == errno.ENOENT:
              raise FileNotFoundError(str(e))
          raise
docs: Contextmanager to wrap file exceptions into identicaly exceptions in py2 and py3.
  
      This should be removed once py2 support is dropped.