Uh oh!
There was an error while loading. Please reload this page.
_codecs: Fix buffer parameters - #9003
Conversation
| def charmap_encode(__str: str, __errors: str | None = ..., __mapping: _CharMap | None = ...) -> tuple[bytes, int]: ... | ||
| def escape_decode(__data: str | bytes, __errors: str | None = ...) -> tuple[str, int]: ... | ||
| def escape_decode(__data: str | ReadableBuffer, __errors: str | None = ...) -> tuple[str, int]: ... | ||
| def escape_encode(__data: bytes, __errors: str | None = ...) -> tuple[bytes, int]: ... |
There was a problem hiding this comment.
This one is really just bytes:
>>> _codecs.escape_encode(bytearray(b"x"))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: escape_encode() argument 1 must be bytes, not bytearray
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
srittau
left a comment
There was a problem hiding this comment.
I've only found this in the Python docs in regards to whether codecs should be able to handle any buffer:
https://docs.python.org/3/library/codecs.html?highlight=codec#codecs.Codec.decode
Codec.decode(input, errors='strict')
[...]
For text encodings and bytes-to-bytes codecs, input must be a bytes object or one which provides the read-only buffer interface – for example, buffer objects and memory mapped files.
But I guess this kind of implies that generally buffer protocol objects are okay where bytes are allowed.
No description provided.