Skip to content

Commit 20189ed

Browse files
committed
Fix wrong return behavior when missing _stream_reader in protocol
1 parent 1b7c5dd commit 20189ed

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

uvloop/loop.pyx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,17 +1617,15 @@ cdef class Loop:
16171617
call_connection_made=False)
16181618

16191619
# Transfer buffered data from the old protocol to the new one.
1620-
if not hasattr(protocol, '_stream_reader'):
1621-
return
1622-
1623-
stream_reader = protocol._stream_reader
1624-
if stream_reader is None:
1625-
return
1626-
1627-
buffer = stream_reader._buffer
1628-
if buffer:
1629-
ssl_protocol._incoming.write(buffer)
1630-
buffer.clear()
1620+
stream_buff = None
1621+
if hasattr(protocol, '_stream_reader'):
1622+
stream_reader = protocol._stream_reader
1623+
if stream_reader is not None:
1624+
stream_buff = getattr(stream_reader, '_buffer', None)
1625+
1626+
if stream_buff is not None:
1627+
ssl_protocol._incoming.write(stream_buff)
1628+
stream_buff.clear()
16311629

16321630
# Pause early so that "ssl_protocol.data_received()" doesn't
16331631
# have a chance to get called before "ssl_protocol.connection_made()".

0 commit comments

Comments
 (0)