Skip to content

pythongh-109534: get rid of bytearray as class member #115643

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

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion Lib/asyncio/selector_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@ def _read_ready__get_buffer(self):
return

try:
self._protocol.buffer_updated(nbytes)
self._protocol.buffer_updated(nbytes, buf[:nbytes])
except (SystemExit, KeyboardInterrupt):
raise
except BaseException as exc:
Expand Down
15 changes: 7 additions & 8 deletions Lib/asyncio/sslproto.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ def __init__(self, loop, app_protocol, sslcontext, waiter,
if ssl is None:
raise RuntimeError("stdlib ssl module not available")

self._ssl_buffer = bytearray(self.max_size)
self._ssl_buffer_view = memoryview(self._ssl_buffer)
self._ssl_buffer = None
self._ssl_buffer_view = None

if ssl_handshake_timeout is None:
ssl_handshake_timeout = constants.SSL_HANDSHAKE_TIMEOUT
Expand Down Expand Up @@ -427,13 +427,12 @@ def get_buffer(self, n):
want = n
if want <= 0 or want > self.max_size:
want = self.max_size
if len(self._ssl_buffer) < want:
self._ssl_buffer = bytearray(want)
self._ssl_buffer_view = memoryview(self._ssl_buffer)
return self._ssl_buffer_view
_ssl_buffer = bytearray(want)
_ssl_buffer_view = memoryview(_ssl_buffer)
return _ssl_buffer_view

def buffer_updated(self, nbytes):
self._incoming.write(self._ssl_buffer_view[:nbytes])
def buffer_updated(self, nbytes, buffer):
self._incoming.write(buffer)

if self._state == SSLProtocolState.DO_HANDSHAKE:
self._do_handshake()
Expand Down