Open
Description
For instance, this script passes mypy:
import contextlib
from typing import Iterator
@contextlib.contextmanager
def f() -> Iterator[int]:
return iter([1])
with f():
pass
with f():
raise TypeError('wat')
but fails at runtime (and not in the expected way):
$ python t.py
Traceback (most recent call last):
File "t.py", line 14, in <module>
raise TypeError('wat')
TypeError: wat
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "t.py", line 14, in <module>
raise TypeError('wat')
File "/usr/lib/python3.6/contextlib.py", line 99, in __exit__
self.gen.throw(type, value, traceback)
AttributeError: 'list_iterator' object has no attribute 'throw'