From 867cab7f2542d2a19fd4aa4ad98acb52fba593af Mon Sep 17 00:00:00 2001 From: darko-poljak Date: Sat, 8 Feb 2014 19:11:55 +0100 Subject: [PATCH] make with nested to work with 2.6 --- sweeper/sweeper.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/sweeper/sweeper.py b/sweeper/sweeper.py index 3ec24ee..ad843b7 100644 --- a/sweeper/sweeper.py +++ b/sweeper/sweeper.py @@ -153,14 +153,16 @@ def _fbequal(fpath1, fpath2): False otherwise. fpath1 and fpath2 are file paths. ''' - with open(fpath1, "rb") as f1, open(fpath2, "rb") as f2: - while True: - b1 = f1.read(1) - b2 = f2.read(1) - if b1 != b2: # different bytes - return False - if not b1 or not b2: # end in one or both files - break + # nested to work with 2.6 + with open(fpath1, "rb") as f1: + with open(fpath2, "rb") as f2: + while True: + b1 = f1.read(1) + b2 = f2.read(1) + if b1 != b2: # different bytes + return False + if not b1 or not b2: # end in one or both files + break if not b1 and not b2: # end in both files, files are equal return True # end in one file but not in the other, files aren't equal