Skip to content

io: improve bytes handling #9059

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions stdlib/codecs.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import types
from _typeshed import Self
from _typeshed import ReadableBuffer, Self
from abc import abstractmethod
from collections.abc import Callable, Generator, Iterable
from typing import Any, BinaryIO, Protocol, TextIO
Expand Down Expand Up @@ -173,7 +173,7 @@ class IncrementalDecoder:
errors: str
def __init__(self, errors: str = ...) -> None: ...
@abstractmethod
def decode(self, input: bytes, final: bool = ...) -> str: ...
def decode(self, input: ReadableBuffer, final: bool = ...) -> str: ...
def reset(self) -> None: ...
def getstate(self) -> tuple[bytes, int]: ...
def setstate(self, state: tuple[bytes, int]) -> None: ...
Expand All @@ -190,8 +190,8 @@ class BufferedIncrementalDecoder(IncrementalDecoder):
buffer: bytes
def __init__(self, errors: str = ...) -> None: ...
@abstractmethod
def _buffer_decode(self, input: bytes, errors: str, final: bool) -> tuple[str, int]: ...
def decode(self, input: bytes, final: bool = ...) -> str: ...
def _buffer_decode(self, input: ReadableBuffer, errors: str, final: bool) -> tuple[str, int]: ...
def decode(self, input: ReadableBuffer, final: bool = ...) -> str: ...

# TODO: it is not possible to specify the requirement that all other
# attributes and methods are passed-through from the stream.
Expand Down
2 changes: 1 addition & 1 deletion stdlib/io.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class StringIO(TextIOWrapper):

class IncrementalNewlineDecoder(codecs.IncrementalDecoder):
def __init__(self, decoder: codecs.IncrementalDecoder | None, translate: bool, errors: str = ...) -> None: ...
def decode(self, input: bytes | str, final: bool = ...) -> str: ...
def decode(self, input: ReadableBuffer | str, final: bool = ...) -> str: ...
@property
def newlines(self) -> str | tuple[str, ...] | None: ...
def setstate(self, __state: tuple[bytes, int]) -> None: ...