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

Skip to content

Commit 3f438a9

Browse files
authored
asyncio: Remove asyncio/compat.py (#4606)
The asyncio/compat.py file was written to support Python < 3.5 and Python < 3.5.2. But Python 3.5 doesn't accept bugfixes anymore, only security fixes. There is no more need to backport bugfixes to Python 3.5, and so no need to have a single code base for Python 3.5, 3.6 and 3.7. Say hello (again) to "async" and "await", who became real keywords in Python 3.7 ;-)
1 parent a10dc3e commit 3f438a9

7 files changed

Lines changed: 37 additions & 60 deletions

File tree

Lib/asyncio/compat.py

Lines changed: 0 additions & 6 deletions
This file was deleted.

Lib/asyncio/coroutines.py

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import traceback
1010
import types
1111

12-
from . import compat
1312
from . import constants
1413
from . import events
1514
from . import base_futures
@@ -151,35 +150,33 @@ def gi_running(self):
151150
def gi_code(self):
152151
return self.gen.gi_code
153152

154-
if compat.PY35:
155-
156-
def __await__(self):
157-
cr_await = getattr(self.gen, 'cr_await', None)
158-
if cr_await is not None:
159-
raise RuntimeError(
160-
"Cannot await on coroutine {!r} while it's "
161-
"awaiting for {!r}".format(self.gen, cr_await))
162-
return self
153+
def __await__(self):
154+
cr_await = getattr(self.gen, 'cr_await', None)
155+
if cr_await is not None:
156+
raise RuntimeError(
157+
"Cannot await on coroutine {!r} while it's "
158+
"awaiting for {!r}".format(self.gen, cr_await))
159+
return self
163160

164-
@property
165-
def gi_yieldfrom(self):
166-
return self.gen.gi_yieldfrom
161+
@property
162+
def gi_yieldfrom(self):
163+
return self.gen.gi_yieldfrom
167164

168-
@property
169-
def cr_await(self):
170-
return self.gen.cr_await
165+
@property
166+
def cr_await(self):
167+
return self.gen.cr_await
171168

172-
@property
173-
def cr_running(self):
174-
return self.gen.cr_running
169+
@property
170+
def cr_running(self):
171+
return self.gen.cr_running
175172

176-
@property
177-
def cr_code(self):
178-
return self.gen.cr_code
173+
@property
174+
def cr_code(self):
175+
return self.gen.cr_code
179176

180-
@property
181-
def cr_frame(self):
182-
return self.gen.cr_frame
177+
@property
178+
def cr_frame(self):
179+
return self.gen.cr_frame
183180

184181
def __del__(self):
185182
# Be careful accessing self.gen.frame -- self.gen might not exist.

Lib/asyncio/futures.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import traceback
1010

1111
from . import base_futures
12-
from . import compat
1312
from . import events
1413

1514

@@ -238,8 +237,7 @@ def __iter__(self):
238237
assert self.done(), "yield from wasn't used with future"
239238
return self.result() # May raise too.
240239

241-
if compat.PY35:
242-
__await__ = __iter__ # make compatible with 'await' expression
240+
__await__ = __iter__ # make compatible with 'await' expression
243241

244242

245243
# Needed for testing purposes.

Lib/asyncio/locks.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import collections
66

7-
from . import compat
87
from . import events
98
from . import futures
109
from .coroutines import coroutine
@@ -67,23 +66,21 @@ def __iter__(self):
6766
yield from self.acquire()
6867
return _ContextManager(self)
6968

70-
if compat.PY35:
71-
72-
def __await__(self):
73-
# To make "with await lock" work.
74-
yield from self.acquire()
75-
return _ContextManager(self)
69+
def __await__(self):
70+
# To make "with await lock" work.
71+
yield from self.acquire()
72+
return _ContextManager(self)
7673

77-
@coroutine
78-
def __aenter__(self):
79-
yield from self.acquire()
80-
# We have no use for the "as ..." clause in the with
81-
# statement for locks.
82-
return None
74+
@coroutine
75+
def __aenter__(self):
76+
yield from self.acquire()
77+
# We have no use for the "as ..." clause in the with
78+
# statement for locks.
79+
return None
8380

84-
@coroutine
85-
def __aexit__(self, exc_type, exc, tb):
86-
self.release()
81+
@coroutine
82+
def __aexit__(self, exc_type, exc, tb):
83+
self.release()
8784

8885

8986
class Lock(_ContextManagerMixin):

Lib/asyncio/queues.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import collections
66
import heapq
77

8-
from . import compat
98
from . import events
109
from . import locks
1110
from .coroutines import coroutine
@@ -251,9 +250,3 @@ def _put(self, item):
251250

252251
def _get(self):
253252
return self._queue.pop()
254-
255-
256-
if not compat.PY35:
257-
JoinableQueue = Queue
258-
"""Deprecated alias for Queue."""
259-
__all__.append('JoinableQueue')

Lib/asyncio/streams.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
__all__.extend(['open_unix_connection', 'start_unix_server'])
1313

1414
from . import coroutines
15-
from . import compat
1615
from . import events
1716
from . import protocols
1817
from .coroutines import coroutine

Lib/asyncio/tasks.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import weakref
1414

1515
from . import base_tasks
16-
from . import compat
1716
from . import coroutines
1817
from . import events
1918
from . import futures
@@ -525,7 +524,7 @@ def ensure_future(coro_or_future, *, loop=None):
525524
if task._source_traceback:
526525
del task._source_traceback[-1]
527526
return task
528-
elif compat.PY35 and inspect.isawaitable(coro_or_future):
527+
elif inspect.isawaitable(coro_or_future):
529528
return ensure_future(_wrap_awaitable(coro_or_future), loop=loop)
530529
else:
531530
raise TypeError('An asyncio.Future, a coroutine or an awaitable is '

0 commit comments

Comments
 (0)