+++ /dev/null
-"""Compatibility helpers for the different Python versions."""
-
-import sys
-
-PY35 = sys.version_info >= (3, 5)
-PY352 = sys.version_info >= (3, 5, 2)
import traceback
import types
-from . import compat
from . import constants
from . import events
from . import base_futures
def gi_code(self):
return self.gen.gi_code
- if compat.PY35:
-
- def __await__(self):
- cr_await = getattr(self.gen, 'cr_await', None)
- if cr_await is not None:
- raise RuntimeError(
- "Cannot await on coroutine {!r} while it's "
- "awaiting for {!r}".format(self.gen, cr_await))
- return self
+ def __await__(self):
+ cr_await = getattr(self.gen, 'cr_await', None)
+ if cr_await is not None:
+ raise RuntimeError(
+ "Cannot await on coroutine {!r} while it's "
+ "awaiting for {!r}".format(self.gen, cr_await))
+ return self
- @property
- def gi_yieldfrom(self):
- return self.gen.gi_yieldfrom
+ @property
+ def gi_yieldfrom(self):
+ return self.gen.gi_yieldfrom
- @property
- def cr_await(self):
- return self.gen.cr_await
+ @property
+ def cr_await(self):
+ return self.gen.cr_await
- @property
- def cr_running(self):
- return self.gen.cr_running
+ @property
+ def cr_running(self):
+ return self.gen.cr_running
- @property
- def cr_code(self):
- return self.gen.cr_code
+ @property
+ def cr_code(self):
+ return self.gen.cr_code
- @property
- def cr_frame(self):
- return self.gen.cr_frame
+ @property
+ def cr_frame(self):
+ return self.gen.cr_frame
def __del__(self):
# Be careful accessing self.gen.frame -- self.gen might not exist.
import traceback
from . import base_futures
-from . import compat
from . import events
assert self.done(), "yield from wasn't used with future"
return self.result() # May raise too.
- if compat.PY35:
- __await__ = __iter__ # make compatible with 'await' expression
+ __await__ = __iter__ # make compatible with 'await' expression
# Needed for testing purposes.
import collections
-from . import compat
from . import events
from . import futures
from .coroutines import coroutine
yield from self.acquire()
return _ContextManager(self)
- if compat.PY35:
-
- def __await__(self):
- # To make "with await lock" work.
- yield from self.acquire()
- return _ContextManager(self)
+ def __await__(self):
+ # To make "with await lock" work.
+ yield from self.acquire()
+ return _ContextManager(self)
- @coroutine
- def __aenter__(self):
- yield from self.acquire()
- # We have no use for the "as ..." clause in the with
- # statement for locks.
- return None
+ @coroutine
+ def __aenter__(self):
+ yield from self.acquire()
+ # We have no use for the "as ..." clause in the with
+ # statement for locks.
+ return None
- @coroutine
- def __aexit__(self, exc_type, exc, tb):
- self.release()
+ @coroutine
+ def __aexit__(self, exc_type, exc, tb):
+ self.release()
class Lock(_ContextManagerMixin):
import collections
import heapq
-from . import compat
from . import events
from . import locks
from .coroutines import coroutine
def _get(self):
return self._queue.pop()
-
-
-if not compat.PY35:
- JoinableQueue = Queue
- """Deprecated alias for Queue."""
- __all__.append('JoinableQueue')
__all__.extend(['open_unix_connection', 'start_unix_server'])
from . import coroutines
-from . import compat
from . import events
from . import protocols
from .coroutines import coroutine
import weakref
from . import base_tasks
-from . import compat
from . import coroutines
from . import events
from . import futures
if task._source_traceback:
del task._source_traceback[-1]
return task
- elif compat.PY35 and inspect.isawaitable(coro_or_future):
+ elif inspect.isawaitable(coro_or_future):
return ensure_future(_wrap_awaitable(coro_or_future), loop=loop)
else:
raise TypeError('An asyncio.Future, a coroutine or an awaitable is '