[issue3842] can't run close through itertools.chain on inner generator

2008-09-12 Thread Raymond Hettinger
Raymond Hettinger <[EMAIL PROTECTED]> added the comment: Sorry, am going to reject this. The use cases are somewhat uncommon and I don't want to clutter-up tools that need to remain as simple as possible. The pure python code for chain() is so simple that it's not hard to roll your own version

[issue3842] can't run close through itertools.chain on inner generator

2008-09-12 Thread Bruce Frederiksen
Bruce Frederiksen <[EMAIL PROTECTED]> added the comment: What you propose is not portable code. It won't work on jython or ironpython or pypy because they don't have reference counting garbage collectors that immediately reclaim objects. Also I'm not asking that all c-based iterators grow a '

[issue3842] can't run close through itertools.chain on inner generator

2008-09-12 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc <[EMAIL PROTECTED]> added the comment: You somehow must tell the iterator that you are done with it. This is best done by a "del c" in your first snippet, since c is the last reference to the iterator. To do this in a function (or a context manager), the trick is to wrap the

[issue3842] can't run close through itertools.chain on inner generator

2008-09-11 Thread Benjamin Peterson
Changes by Benjamin Peterson <[EMAIL PROTECTED]>: -- assignee: -> rhettinger nosy: +rhettinger versions: +Python 2.7, Python 3.1 -Python 3.0 ___ Python tracker <[EMAIL PROTECTED]> ___

[issue3842] can't run close through itertools.chain on inner generator

2008-09-11 Thread Bruce Frederiksen
New submission from Bruce Frederiksen <[EMAIL PROTECTED]>: There is no way to get generators to clean up (run their 'finally' clause) when used as an inner iterable to chain: >>> def gen(n): ... try: ... # do stuff yielding values ... finally: ... # clean up >>> c = chain