Martin Panter added the comment: Guido are you saying in the following code, the “finally” message is not guaranteed to be printed out? Or just that you cannot limit a ResourceWarning to garbage collection?
def g(): try: yield "item" finally: # Run at exhaustion, close(), and garbage collection print("finally") gi = g() try: item = next(gi) print(item / 2) # Oops, TypeError finally: # Should be run as the exception passes through. GeneratorExit is raised inside the generator, causing the other “finally” block to execute. All before the original exception is caught and a traceback is printed. gi.close() But as I understand it, os.scandir() is not a generator, so none of these problems would apply. ---------- nosy: +martin.panter _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25994> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com