Author serhiy.storchaka
Recipients serhiy.storchaka, yselivanov
Date 2018-03-10.13:10:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1520687441.8.0.467229070634.issue33041@psf.upfronthosting.co.za>
In-reply-to
Content
There is a number of issues with "async for".

1. When assigning to the target raises StopAsyncIteration (in custom __setitem__, __setattr__ or __iter__) it will be silenced and will cause to stop iteration.

2. StopAsyncIteration is dynamically looked up in globals. If set the global StopAsyncIteration or delete it from builtins (for example at the shutdown stage), this will break any "async for".

3. The f_lineno setter doesn't handle jumping into or out of the "async for" block. Jumping into is not forbidden, and jumping out doesn't update the stack correctly. This can cause a crash or incorrect behavior (like iterating wrong loop).

4. The compiler doesn't check all errors when creating new blocks. Some blocks are not used. And the resulting bytecode is suboptimal.

I'll create a series of pull request for fixing all this issue. Some of them can be backported. Others require changes in bytecode or are too hard for implementing in 3.7 and earlier versions (the related code was changed in issue17611). Some of them depend on other PRs or other issues (like issue33026) and need to wait until their be merged.
History
Date User Action Args
2018-03-10 13:10:41serhiy.storchakasetrecipients: + serhiy.storchaka, yselivanov
2018-03-10 13:10:41serhiy.storchakasetmessageid: <1520687441.8.0.467229070634.issue33041@psf.upfronthosting.co.za>
2018-03-10 13:10:41serhiy.storchakalinkissue33041 messages
2018-03-10 13:10:41serhiy.storchakacreate