diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-03-21 17:31:58 +0000 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-03-21 17:31:58 +0000 |
commit | f07d0026da4330724ae2f17fb453db3d7f539e56 (patch) | |
tree | c5e5b64602dc0ed367980f0630289a003953c4ce /Lib/filecmp.py | |
parent | Blocked revisions 70286,70290,70292-70293,70295-70296,70298,70300,70305,70315... (diff) | |
download | cpython-f07d0026da4330724ae2f17fb453db3d7f539e56.tar.gz cpython-f07d0026da4330724ae2f17fb453db3d7f539e56.tar.bz2 cpython-f07d0026da4330724ae2f17fb453db3d7f539e56.zip |
Merged revisions 70342,70385-70387,70389-70390,70392-70393,70395,70400,70405-70406,70418,70438,70464,70468 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r70342 | georg.brandl | 2009-03-13 14:03:58 -0500 (Fri, 13 Mar 2009) | 1 line
#5486: typos.
........
r70385 | benjamin.peterson | 2009-03-15 09:38:55 -0500 (Sun, 15 Mar 2009) | 1 line
fix tuple.index() error message #5495
........
r70386 | georg.brandl | 2009-03-15 16:32:06 -0500 (Sun, 15 Mar 2009) | 1 line
#5496: fix docstring of lookup().
........
r70387 | georg.brandl | 2009-03-15 16:37:16 -0500 (Sun, 15 Mar 2009) | 1 line
#5493: clarify __nonzero__ docs.
........
r70389 | georg.brandl | 2009-03-15 16:43:38 -0500 (Sun, 15 Mar 2009) | 1 line
Fix a small nit in the error message if bool() falls back on __len__ and it returns the wrong type: it would tell the user that __nonzero__ should return bool or int.
........
r70390 | georg.brandl | 2009-03-15 16:44:43 -0500 (Sun, 15 Mar 2009) | 1 line
#5491: clarify nested() semantics.
........
r70392 | georg.brandl | 2009-03-15 16:46:00 -0500 (Sun, 15 Mar 2009) | 1 line
#5488: add missing struct member.
........
r70393 | georg.brandl | 2009-03-15 16:47:42 -0500 (Sun, 15 Mar 2009) | 1 line
#5478: fix copy-paste oversight in function signature.
........
r70395 | georg.brandl | 2009-03-15 16:51:48 -0500 (Sun, 15 Mar 2009) | 1 line
#5276: document IDLESTARTUP and .Idle.py.
........
r70400 | georg.brandl | 2009-03-15 16:59:37 -0500 (Sun, 15 Mar 2009) | 3 lines
Fix markup in re docs and give a mail address in regex howto, so that
the recommendation to send suggestions to the author can be followed.
........
r70405 | georg.brandl | 2009-03-15 17:11:07 -0500 (Sun, 15 Mar 2009) | 7 lines
Move the previously local import of threading to module level.
This is cleaner and avoids lockups in obscure cases where a Queue
is instantiated while the import lock is already held by another thread.
OKed by Tim Peters.
........
r70406 | hirokazu.yamamoto | 2009-03-15 17:43:14 -0500 (Sun, 15 Mar 2009) | 1 line
Added skip for old MSVC.
........
r70418 | georg.brandl | 2009-03-16 14:42:03 -0500 (Mon, 16 Mar 2009) | 1 line
Add token markup.
........
r70438 | benjamin.peterson | 2009-03-17 15:29:51 -0500 (Tue, 17 Mar 2009) | 1 line
I thought this was begging for an example
........
r70464 | benjamin.peterson | 2009-03-18 15:58:09 -0500 (Wed, 18 Mar 2009) | 1 line
a much better example
........
r70468 | benjamin.peterson | 2009-03-18 22:04:31 -0500 (Wed, 18 Mar 2009) | 1 line
close files after comparing them
........
Diffstat (limited to 'Lib/filecmp.py')
-rw-r--r-- | Lib/filecmp.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Lib/filecmp.py b/Lib/filecmp.py index 6dcebaa23df..4cbb0d682b9 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. # |