def posixfile(name, mode="r", buffering=-1): """Open a file with even more POSIX-like semantics""" try: fp = osutil.posixfile(name, mode, buffering) # may raise WindowsError return _fixseek(fp, mode) except WindowsError as err: # convert to a friendlier exception raise IOError(err.errno, "%s: %s" % (name, encoding.strtolocal(err.strerror)))
def posixfile(name, mode="r", buffering=-1): # type: (str, str, int) -> IO """Open a file with even more POSIX-like semantics""" try: fp = osutil.posixfile(name, mode, buffering) # may raise WindowsError return _fixseek(fp, mode) # pyre-fixme[10]: Name `WindowsError` is used but not defined. except WindowsError as err: # convert to a friendlier exception raise IOError(err.errno, "%s: %s" % (name, encoding.strtolocal(err.strerror)))
def posixfile(name: str, mode: str = "r", buffering: int = -1) -> "IO": """Open a file with even more POSIX-like semantics""" try: fp = osutil.posixfile(name, mode, buffering) # may raise WindowsError # PyFile_FromFd() ignores the name, and seems to report fp.name as the # underlying file descriptor. if sys.version_info[0] >= 3: fp = fdproxy(name, fp) return _fixseek(fp, mode) # pyre-fixme[10]: Name `WindowsError` is used but not defined. except WindowsError as err: # convert to a friendlier exception raise IOError(err.errno, "%s: %s" % (name, encoding.strtolocal(err.strerror)))