Oren Tirosh writes: > Currently, when a generator yields and is never resumed it just dies > silently. I suggest that it would be resumed one last time with an=20 > AbortIteration exception raised at the yield statement. [...] > The difference is that this exception=20 > based system does not make such a strong guarantee as try/finally - it = > will be triggered when the iteration is aborted by break, return or an = > exception in the looping scope but not by a __del__ of a generator=20 > object dropping to refcnt of 0 so it should be "Jythonially correct". Essentially, you're proposing that we USUALLY but not ALWAYS guarantee to call __leave__ (aka __exit__). To me, this suffers from the same problem that your generators patch had... guarantees need to be solid! In the case of generators, I think it's better saying "yield cannot be used inside of try-finally" than saying "if yield is used inside of try-finally then on rare occasions the finally clause may not execute". Similarly, I think if we plan to use this for problems like resource=20 allocation-deallocation, then we'd better not say "__leave__ will usually be called" -- that's practically useless. We need a solid guarantee. -- Michael Chermside
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4