From: Tim Peters Date: Tue, 14 Feb 2006 17:41:18 +0000 (+0000) Subject: New test code failed to close the file. This caused X-Git-Tag: v2.5a0~681 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cffcfed1263a255386c0da50709d6abc18accaab;p=python New test code failed to close the file. This caused test_file to fail on Windows in reality (can't delete a still-open file), but a new bare "except:" hid that test_file failed on Windows, and leaving behind the still-open TESTFN caused a cascade of bogus failures in later tests. So, close the file, and stop hiding failure to unlink. --- diff --git a/Lib/test/test_file.py b/Lib/test/test_file.py index 69501dfe08..efb06f44e4 100644 --- a/Lib/test/test_file.py +++ b/Lib/test/test_file.py @@ -323,18 +323,17 @@ try: "failed. Got %r, expected %r" % (line, testline)) # Reading after iteration hit EOF shouldn't hurt either f = open(TESTFN) - for line in f: - pass try: - f.readline() - f.readinto(buf) - f.read() - f.readlines() - except ValueError: - raise TestFailed("read* failed after next() consumed file") + for line in f: + pass + try: + f.readline() + f.readinto(buf) + f.read() + f.readlines() + except ValueError: + raise TestFailed("read* failed after next() consumed file") + finally: + f.close() finally: - # Bare 'except' so as not to mask errors in the test - try: - os.unlink(TESTFN) - except: - pass + os.unlink(TESTFN)