[pypy-svn] r61529 - pypy/trunk/lib-python/modified-2.5.2
afa at codespeak.net
afa at codespeak.net
Tue Feb 3 02:06:09 CET 2009
Author: afa
Date: Tue Feb 3 02:06:08 2009
New Revision: 61529
Added:
pypy/trunk/lib-python/modified-2.5.2/filecmp.py
- copied, changed from r61434, pypy/trunk/lib-python/2.5.2/filecmp.py
Log:
Fix test_filecmp on Windows, by closing opened files before the tests try to unlink them.
Copied: pypy/trunk/lib-python/modified-2.5.2/filecmp.py (from r61434, pypy/trunk/lib-python/2.5.2/filecmp.py)
==============================================================================
--- pypy/trunk/lib-python/2.5.2/filecmp.py (original)
+++ pypy/trunk/lib-python/modified-2.5.2/filecmp.py Tue Feb 3 02:06:08 2009
@@ -63,15 +63,22 @@
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
+ fp1, fp2 = None, None
+ try:
+ 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
+ finally:
+ if fp1:
+ fp1.close()
+ if fp2:
+ fp2.close()
# Directory comparison class.
#
More information about the Pypy-commit
mailing list