This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author asksol
Recipients asksol
Date 2019-03-23.00:15:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1553300107.21.0.160175909039.issue36403@roundup.psfhosted.org>
In-reply-to
Content
We use finally blocks in ``__aiter__`` like this:

```
class AsyncFinallyIterator:

   def __aiter__(self):
       for i in range(10):
           try:
               yield i
           finally:
               print('FINALLY')
```

Attached is a test for both iterators and async iterators.
The tests pass on Python 3.6, but only the non-async iterator test pass under Python 3.7.

Thanks for your attention!


This worked perfectly well in Python 3.6, but stopped working in Python 3.7.

I also verified that Iterator supports the same construct (and this works in both Python 3.6 and 3.7):

```

class FinallyIterator:

    def __iter__(self):
        for i in range(10):
            try:
                yield i
            finally:
                print('FINALLY')
```
History
Date User Action Args
2019-03-23 00:15:07asksolsetrecipients: + asksol
2019-03-23 00:15:07asksolsetmessageid: <1553300107.21.0.160175909039.issue36403@roundup.psfhosted.org>
2019-03-23 00:15:07asksollinkissue36403 messages
2019-03-23 00:15:06asksolcreate