From 74ea60c898077625c149771a36a2fefdca8d6951 Mon Sep 17 00:00:00 2001 From: Stephen Morton Date: Sat, 9 Dec 2023 19:21:41 -0800 Subject: [PATCH] io.IncrementalNewlineDecoder is not a subclass of codecs.IncrementalDecoder The documentation says that this class "inherits codecs.IncrementalDecoder", but it's not true for the C implementation. The python implementation, _pyio.IncrementalNewlineDecoder, *does* inherit from codecs.IncrementalDecoder, but that's not the implementation that you get with `from io import IncrementalNewlineDecoder`. cpython has a ticket for this issue here: https://github.com/python/cpython/issues/75903 In the meantime, I think this is more correct. Related to https://github.com/python/typeshed/issues/3968 --- stdlib/io.pyi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stdlib/io.pyi b/stdlib/io.pyi index ee4eda1b4eb0..950cd8d9eeb1 100644 --- a/stdlib/io.pyi +++ b/stdlib/io.pyi @@ -193,11 +193,13 @@ class StringIO(TextIOWrapper): name: Any def getvalue(self) -> str: ... -class IncrementalNewlineDecoder(codecs.IncrementalDecoder): +class IncrementalNewlineDecoder: def __init__(self, decoder: codecs.IncrementalDecoder | None, translate: bool, errors: str = ...) -> None: ... def decode(self, input: ReadableBuffer | str, final: bool = False) -> str: ... @property def newlines(self) -> str | tuple[str, ...] | None: ... + def reset(self) -> None: ... + def getstate(self) -> tuple[bytes, int]: ... def setstate(self, __state: tuple[bytes, int]) -> None: ... if sys.version_info >= (3, 10):