]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-95105: Return Iterator from wsgiref.types.InputStream.__iter__ (#95106)
authorShantanu <12621235+hauntsaninja@users.noreply.github.com>
Thu, 21 Jul 2022 20:26:04 +0000 (13:26 -0700)
committerGitHub <noreply@github.com>
Thu, 21 Jul 2022 20:26:04 +0000 (13:26 -0700)
Lib/wsgiref/types.py
Misc/NEWS.d/next/Library/2022-07-21-19-55-49.gh-issue-95105.BIX2Km.rst [new file with mode: 0644]

index 9e74a6c7312b19b051fb67b0c480660964fe01f3..ef0aead5b28b647bd1ad49fef80a490fbd2dc1a8 100644 (file)
@@ -1,6 +1,6 @@
 """WSGI-related types for static type checking"""
 
-from collections.abc import Callable, Iterable
+from collections.abc import Callable, Iterable, Iterator
 from types import TracebackType
 from typing import Any, Protocol, TypeAlias
 
@@ -35,7 +35,7 @@ class InputStream(Protocol):
     def read(self, size: int = ..., /) -> bytes: ...
     def readline(self, size: int = ..., /) -> bytes: ...
     def readlines(self, hint: int = ..., /) -> list[bytes]: ...
-    def __iter__(self) -> Iterable[bytes]: ...
+    def __iter__(self) -> Iterator[bytes]: ...
 
 class ErrorStream(Protocol):
     """WSGI error stream as defined in PEP 3333"""
diff --git a/Misc/NEWS.d/next/Library/2022-07-21-19-55-49.gh-issue-95105.BIX2Km.rst b/Misc/NEWS.d/next/Library/2022-07-21-19-55-49.gh-issue-95105.BIX2Km.rst
new file mode 100644 (file)
index 0000000..58af62b
--- /dev/null
@@ -0,0 +1 @@
+:meth:`wsgiref.types.InputStream.__iter__` should return ``Iterator[bytes]``, not ``Iterable[bytes]``. Patch by Shantanu Jain.