Details
Description
for item in enumerator:
pass
should be equivalent to:
try:
e=enumerator.GetEnumerator():
while e.MoveNext():
item = e.Current
ensure:
cast(IDisposable, e).Dispose() if e isa IDisposable
for item in enumerator:
pass
should be equivalent to:
try:
e=enumerator.GetEnumerator():
while e.MoveNext():
item = e.Current
ensure:
cast(IDisposable, e).Dispose() if e isa IDisposable
This doesn't work well with generator methods since they are implemented using branch instructions and it's not possible to branch into a try block.