mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-141968: use bytearray.take_bytes in encodings.idna (#141975)
This commit is contained in:
parent
9dbf77beb6
commit
9ac14288d7
2 changed files with 5 additions and 2 deletions
|
|
@ -226,7 +226,8 @@ def encode(self, input, errors='strict'):
|
|||
offset + exc.end,
|
||||
exc.reason,
|
||||
)
|
||||
return bytes(result+trailing_dot), len(input)
|
||||
result += trailing_dot
|
||||
return result.take_bytes(), len(input)
|
||||
|
||||
def decode(self, input, errors='strict'):
|
||||
|
||||
|
|
@ -311,7 +312,7 @@ def _buffer_encode(self, input, errors, final):
|
|||
|
||||
result += trailing_dot
|
||||
size += len(trailing_dot)
|
||||
return (bytes(result), size)
|
||||
return (result.take_bytes(), size)
|
||||
|
||||
class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
|
||||
def _buffer_decode(self, input, errors, final):
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
Remove data copy from :mod:`encodings.idna` :meth:`~codecs.Codec.encode` and
|
||||
:meth:`~codecs.IncrementalEncoder.encode` by using :func:`bytearray.take_bytes`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue