From d43cf2b3c134480cbaab0356d5dd4c7090cd33b2 Mon Sep 17 00:00:00 2001 From: Jon Dowland Date: Wed, 16 May 2012 15:41:23 +0100 Subject: [PATCH] rewrite asserts to be side-effect free Two asserts changed program state, and so problems could occur if the asserts are not executed (such as when PYTHONOPTIMIZE is fiddled with). Move the side-effect code out of the assert and test only previously calculated results. --- lib/bup/git.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/bup/git.py b/lib/bup/git.py index 5cb2829..b999a09 100644 --- a/lib/bup/git.py +++ b/lib/bup/git.py @@ -959,7 +959,8 @@ class CatPipe: if not self.p or self.p.poll() != None: self._restart() assert(self.p) - assert(self.p.poll() == None) + r = self.p.poll() + assert(r == None) if self.inprogress: log('_fast_get: opening %r while %r is open\n' % (id, self.inprogress)) @@ -985,7 +986,8 @@ class CatPipe: yield type for blob in it: yield blob - assert(self.p.stdout.readline() == '\n') + l = self.p.stdout.readline() + assert(l == '\n') self.inprogress = None except Exception, e: it.abort() -- 2.39.5