diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/distutils/tests/test_msvc9compiler.py | 4 | ||||
-rw-r--r-- | Lib/filecmp.py | 18 |
2 files changed, 13 insertions, 9 deletions
diff --git a/Lib/distutils/tests/test_msvc9compiler.py b/Lib/distutils/tests/test_msvc9compiler.py index e7d1620..aefadd6 100644 --- a/Lib/distutils/tests/test_msvc9compiler.py +++ b/Lib/distutils/tests/test_msvc9compiler.py @@ -34,6 +34,10 @@ class msvc9compilerTestCase(unittest.TestCase): if sys.platform != 'win32': # this test is only for win32 return + from distutils.msvccompiler import get_build_version + if get_build_version() < 8.0: + # this test is only for MSVC8.0 or above + return from distutils.msvc9compiler import Reg self.assertRaises(KeyError, Reg.get_value, 'xxx', 'xxx') diff --git a/Lib/filecmp.py b/Lib/filecmp.py index 6dcebaa..4cbb0d6 100644 --- a/Lib/filecmp.py +++ b/Lib/filecmp.py @@ -11,6 +11,7 @@ Functions: import os import stat +import contextlib from itertools import filterfalse __all__ = ["cmp","dircmp","cmpfiles"] @@ -62,15 +63,14 @@ def _sig(st): def _do_cmp(f1, f2): bufsize = BUFSIZE - fp1 = open(f1, 'rb') - fp2 = open(f2, 'rb') - while True: - b1 = fp1.read(bufsize) - b2 = fp2.read(bufsize) - if b1 != b2: - return False - if not b1: - return True + with contextlib.nested(open(f1, 'rb'), open(f2, 'rb')) as (fp1, fp2): + while True: + b1 = fp1.read(bufsize) + b2 = fp2.read(bufsize) + if b1 != b2: + return False + if not b1: + return True # Directory comparison class. # |