typecheck-v2
Ibrahim Numanagić 2025-02-26 11:10:51 -08:00
parent 205351bdab
commit d13e0ae245
1 changed files with 7 additions and 1 deletions

View File

@ -17,6 +17,12 @@ class File:
raise IOError(f"file {path} could not be opened")
self._reset()
def __init__(self, fd: int, mode: str):
self.fp = _C.fdopen(fd, mode.c_str())
if not self.fp:
raise IOError(f"file descriptor {fd} could not be opened")
self._reset()
def _errcheck(self, msg: str):
err = int(_C.ferror(self.fp))
if err:
@ -392,7 +398,7 @@ class bzFile:
return i
def open(path: str, mode: str = "r") -> File:
def open(path, mode: str = "r") -> File:
return File(path, mode)
def gzopen(path: str, mode: str = "r") -> gzFile: