diff --git a/Lib/asyncio/proactor_events.py b/Lib/asyncio/proactor_events.py index 7132300a564..a1e2fef6d17 100644 --- a/Lib/asyncio/proactor_events.py +++ b/Lib/asyncio/proactor_events.py @@ -21,9 +21,8 @@ class _ProactorBasePipeTransport(transports._FlowControlMixin, def __init__(self, loop, sock, protocol, waiter=None, extra=None, server=None): - super().__init__(extra) + super().__init__(extra, loop) self._set_extra(sock) - self._loop = loop self._sock = sock self._protocol = protocol self._server = server diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py index c5debf8f02b..116d380157d 100644 --- a/Lib/asyncio/selector_events.py +++ b/Lib/asyncio/selector_events.py @@ -447,7 +447,7 @@ class _SelectorTransport(transports._FlowControlMixin, _buffer_factory = bytearray # Constructs initial value for self._buffer. def __init__(self, loop, sock, protocol, extra, server=None): - super().__init__(extra) + super().__init__(extra, loop) self._extra['socket'] = sock self._extra['sockname'] = sock.getsockname() if 'peername' not in self._extra: @@ -455,7 +455,6 @@ class _SelectorTransport(transports._FlowControlMixin, self._extra['peername'] = sock.getpeername() except socket.error: self._extra['peername'] = None - self._loop = loop self._sock = sock self._sock_fd = sock.fileno() self._protocol = protocol diff --git a/Lib/asyncio/transports.py b/Lib/asyncio/transports.py index 3caf853f9eb..22df3c7aede 100644 --- a/Lib/asyncio/transports.py +++ b/Lib/asyncio/transports.py @@ -238,8 +238,10 @@ class _FlowControlMixin(Transport): resume_writing() may be called. """ - def __init__(self, extra=None): + def __init__(self, extra=None, loop=None): super().__init__(extra) + assert loop is not None + self._loop = loop self._protocol_paused = False self._set_write_buffer_limits() diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py index 93c8c1c8197..b16f946ae4b 100644 --- a/Lib/asyncio/unix_events.py +++ b/Lib/asyncio/unix_events.py @@ -369,9 +369,8 @@ class _UnixWritePipeTransport(transports._FlowControlMixin, transports.WriteTransport): def __init__(self, loop, pipe, protocol, waiter=None, extra=None): - super().__init__(extra) + super().__init__(extra, loop) self._extra['pipe'] = pipe - self._loop = loop self._pipe = pipe self._fileno = pipe.fileno() mode = os.fstat(self._fileno).st_mode diff --git a/Lib/test/test_asyncio/test_transports.py b/Lib/test/test_asyncio/test_transports.py index 5be1b7bf895..3b6e3d67075 100644 --- a/Lib/test/test_asyncio/test_transports.py +++ b/Lib/test/test_asyncio/test_transports.py @@ -69,7 +69,8 @@ class TransportTests(unittest.TestCase): def get_write_buffer_size(self): return 512 - transport = MyTransport() + loop = mock.Mock() + transport = MyTransport(loop=loop) transport._protocol = mock.Mock() self.assertFalse(transport._protocol_paused)