I wrote: > The proposed patch is not correct since it doesn't handle "finally" > code that creates a new reference to the generator. It looks like that's not actually a problem since you can't get a hold of a reference to the generator. However, here's another bit of nastiness: $ cat > bad.py import sys import gc def g(): global gen self = gen try: yield 1 finally: gen = self gen = g() gen.next() del gen gc.collect() print gen $ ./python bad.py Segmentation fault (core dumped) Basically, the GC has to be taught that generators can have finalizers and it may not be safe to collect them. If we allow try/finally in generators then they can cause uncollectible garbage. It's not a show stopper but something else to take into consideration. Neil
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