From 2d82e1fb8bcedc75be3ae91f911472931c92490a Mon Sep 17 00:00:00 2001 From: Shantanu Date: Fri, 6 Mar 2020 14:57:06 -0800 Subject: [PATCH] zipfile.ZipFile: fix fp, extract (#3828) * zipfile: fp is None in a lot of error cases * zipfile: pwd can be None in extract Co-authored-by: hauntsaninja <> --- stdlib/2and3/zipfile.pyi | 4 ++-- tests/stubtest_whitelists/py3_common.txt | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/stdlib/2and3/zipfile.pyi b/stdlib/2and3/zipfile.pyi index 36fbc9cf8..8b7974dff 100644 --- a/stdlib/2and3/zipfile.pyi +++ b/stdlib/2and3/zipfile.pyi @@ -66,7 +66,7 @@ class ZipFile: debug: int comment: bytes filelist: List[ZipInfo] - fp: IO[bytes] + fp: Optional[IO[bytes]] NameToInfo: Dict[Text, ZipInfo] start_dir: int # undocumented if sys.version_info >= (3, 8): @@ -102,7 +102,7 @@ class ZipFile: def infolist(self) -> List[ZipInfo]: ... def namelist(self) -> List[Text]: ... def open(self, name: _SZI, mode: Text = ..., pwd: Optional[bytes] = ..., *, force_zip64: bool = ...) -> IO[bytes]: ... - def extract(self, member: _SZI, path: Optional[_SZI] = ..., pwd: bytes = ...) -> str: ... + def extract(self, member: _SZI, path: Optional[_SZI] = ..., pwd: Optional[bytes] = ...) -> str: ... def extractall( self, path: Optional[_Path] = ..., members: Optional[Iterable[Text]] = ..., pwd: Optional[bytes] = ... ) -> None: ... diff --git a/tests/stubtest_whitelists/py3_common.txt b/tests/stubtest_whitelists/py3_common.txt index 6342094df..0f0d3b40c 100644 --- a/tests/stubtest_whitelists/py3_common.txt +++ b/tests/stubtest_whitelists/py3_common.txt @@ -915,6 +915,4 @@ xml.etree.cElementTree.TreeBuilder.start xml.sax.xmlreader.AttributesImpl.has_key zipfile.ZipExtFile.read zipfile.ZipExtFile.readline -zipfile.ZipFile.extract -zipfile.ZipFile.fp zlib.compressobj