[Python-Dev] PEP 492: __aiter__ should return async iterator directly instead of awaitable

Guido van Rossum guido at python.org
Mon Jun 6 16:21:25 EDT 2016


The RC for 3.5.2 is going out coming weekend (see PEP 478
<https://www.python.org/dev/peps/pep-0478/>). We should get this out now,
or make it the first incompatibility in 3.6 (that's also an option; 3.6
feature freeze starts September, see PEP 494
<https://www.python.org/dev/peps/pep-0494/>).

On Mon, Jun 6, 2016 at 1:05 PM, Yury Selivanov <yselivanov.ml at gmail.com>
wrote:

>
>
> On 2016-06-06 4:02 PM, Łukasz Langa wrote:
>
>> The proposed patch fixes the __aiter__ in a backwards compatible way:
>>>
>>> 1. ceval/GET_AITER opcode calls the __aiter__ method.
>>>
>>> 2. If the returned object has an '__anext__' method, GET_AITER silently
>>> wraps it in an awaitable, which is equivalent to the following coroutine:
>>>
>>>    async def wrapper(aiter_result):
>>>        return aiter_result
>>>
>>> 3. If the returned object does not have an '__anext__' method, a
>>> DeprecationWarning is raised.
>>>
>>
>> There’s a problem with this approach. It will force people to write
>> deprecated code because you never know if your library is going to run on
>> 3.5.0 or 3.5.1. Barry, Ubuntu wily, xenial and yakkety currently package
>> 3.5.0 or 3.5.1. When 3.5.2 is going to get released, are they going to get
>> it? I’m pretty sure wily *isn’t* and yakkety *is* but just wanted to
>> confirm; especially with xenial being an LTS release.
>>
>>
> Yes, I agree. OTOH, I don't see any other way of resolving this.
>
> Another option would be to start raising the DeprecationWarning only in
> 3.6.
>
> Yury
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/guido%40python.org
>



-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20160606/e9908a95/attachment.html>


More information about the Python-Dev mailing list