Skip to content

Commit 1d4eed1

Browse files
zipfile: improve bytes handling (#9109)
Technically some uses of `pwd` accept more types, but others use `isinstance()` to enforce only `bytes`. It seems better to keep the same type throughout the module.
1 parent 6639e2e commit 1d4eed1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

stdlib/zipfile.pyi

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import io
22
import sys
3-
from _typeshed import Self, StrOrBytesPath, StrPath
3+
from _typeshed import Self, StrOrBytesPath, StrPath, _BufferWithLen
44
from collections.abc import Callable, Iterable, Iterator
55
from os import PathLike
66
from types import TracebackType
@@ -103,7 +103,7 @@ class ZipFile:
103103
compression: int # undocumented
104104
compresslevel: int | None # undocumented
105105
mode: _ZipFileMode # undocumented
106-
pwd: str | None # undocumented
106+
pwd: bytes | None # undocumented
107107
if sys.version_info >= (3, 11):
108108
@overload
109109
def __init__(
@@ -173,7 +173,11 @@ class ZipFile:
173173
self, filename: StrPath, arcname: StrPath | None = ..., compress_type: int | None = ..., compresslevel: int | None = ...
174174
) -> None: ...
175175
def writestr(
176-
self, zinfo_or_arcname: str | ZipInfo, data: bytes | str, compress_type: int | None = ..., compresslevel: int | None = ...
176+
self,
177+
zinfo_or_arcname: str | ZipInfo,
178+
data: _BufferWithLen | str,
179+
compress_type: int | None = ...,
180+
compresslevel: int | None = ...,
177181
) -> None: ...
178182
if sys.version_info >= (3, 11):
179183
def mkdir(self, zinfo_or_directory_name: str | ZipInfo, mode: int = ...) -> None: ...

0 commit comments

Comments
 (0)