[New-bugs-announce] [issue33041] Issues with "async for"

Serhiy Storchaka report at bugs.python.org
Sat Mar 10 08:10:41 EST 2018


New submission from Serhiy Storchaka <storchaka+cpython at gmail.com>:

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.

----------
assignee: serhiy.storchaka
components: Interpreter Core
messages: 313526
nosy: serhiy.storchaka, yselivanov
priority: normal
severity: normal
status: open
title: Issues with "async for"
type: crash
versions: Python 3.6, Python 3.7, Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33041>
_______________________________________


More information about the New-bugs-announce mailing list