Python 3.5.2/3.6+ compatibility patch for async generator protocol change #1082
Closed
Description
Long story short
Currently the code uses PY_35 flag to define async generators (__aiter__ and __anext__ methods). However, __aiter__ will be changed to a plain method instead of coroutine in the future Python versions starting from Python 3.5.2 (http://bugs.python.org/issue27243).
Though it will follow the standard deprecation process and the code would not break immediately with deprecation warnings, I think we should be aware of this issue.
Expected/Actual behaviour
In all places that define __aiter__ method, it should check also not only if the current version >= 3.5.0 but also 3.5.2.
if PY_35:
@asyncio.coroutine
def __aiter___(self):
...
@asyncio.coroutine
def __anext__(self):
...should become:
if PY_350 or PY_351: # may need to be cleaned up
@asyncio.coroutine
def __aiter___(self):
return self
@asyncio.coroutine
def __anext__(self):
...
elif PY_352:
def __aiter___(self):
return self
@asyncio.coroutine
def __anext__(self):
...Your environment
Python 3.5.2 on MacOS X.