Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 966321e

Browse files
committed
Merge 3.5 (asyncio)
2 parents 0b51fd4 + a05a6ef commit 966321e

7 files changed

Lines changed: 45 additions & 0 deletions

File tree

Lib/asyncio/base_subprocess.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ def __repr__(self):
8787
def _start(self, args, shell, stdin, stdout, stderr, bufsize, **kwargs):
8888
raise NotImplementedError
8989

90+
def set_protocol(self, protocol):
91+
self._protocol = protocol
92+
93+
def get_protocol(self):
94+
return self._protocol
95+
9096
def is_closing(self):
9197
return self._closed
9298

Lib/asyncio/proactor_events.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ def __repr__(self):
6666
def _set_extra(self, sock):
6767
self._extra['pipe'] = sock
6868

69+
def set_protocol(self, protocol):
70+
self._protocol = protocol
71+
72+
def get_protocol(self):
73+
return self._protocol
74+
6975
def is_closing(self):
7076
return self._closing
7177

Lib/asyncio/selector_events.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,12 @@ def __repr__(self):
560560
def abort(self):
561561
self._force_close(None)
562562

563+
def set_protocol(self, protocol):
564+
self._protocol = protocol
565+
566+
def get_protocol(self):
567+
return self._protocol
568+
563569
def is_closing(self):
564570
return self._closing
565571

Lib/asyncio/sslproto.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,12 @@ def get_extra_info(self, name, default=None):
305305
"""Get optional transport information."""
306306
return self._ssl_protocol._get_extra_info(name, default)
307307

308+
def set_protocol(self, protocol):
309+
self._app_protocol = protocol
310+
311+
def get_protocol(self):
312+
return self._app_protocol
313+
308314
def is_closing(self):
309315
return self._closed
310316

Lib/asyncio/transports.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ def close(self):
3333
"""
3434
raise NotImplementedError
3535

36+
def set_protocol(self, protocol):
37+
"""Set a new protocol."""
38+
raise NotImplementedError
39+
40+
def get_protocol(self):
41+
"""Return the current protocol."""
42+
raise NotImplementedError
43+
3644

3745
class ReadTransport(BaseTransport):
3846
"""Interface for read-only transports."""

Lib/asyncio/unix_events.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,12 @@ def pause_reading(self):
374374
def resume_reading(self):
375375
self._loop.add_reader(self._fileno, self._read_ready)
376376

377+
def set_protocol(self, protocol):
378+
self._protocol = protocol
379+
380+
def get_protocol(self):
381+
return self._protocol
382+
377383
def is_closing(self):
378384
return self._closing
379385

@@ -571,6 +577,12 @@ def write_eof(self):
571577
self._loop.remove_reader(self._fileno)
572578
self._loop.call_soon(self._call_connection_lost, None)
573579

580+
def set_protocol(self, protocol):
581+
self._protocol = protocol
582+
583+
def get_protocol(self):
584+
return self._protocol
585+
574586
def is_closing(self):
575587
return self._closing
576588

Lib/test/test_asyncio/test_sslproto.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def ssl_protocol(self, waiter=None):
2525
sslcontext = test_utils.dummy_ssl_context()
2626
app_proto = asyncio.Protocol()
2727
proto = sslproto.SSLProtocol(self.loop, app_proto, sslcontext, waiter)
28+
self.assertIs(proto._app_transport.get_protocol(), app_proto)
2829
self.addCleanup(proto._app_transport.close)
2930
return proto
3031

0 commit comments

Comments
 (0)