Hi, if you are able to, can you try and see whether this patch works to fix the
problem for you? As far as I can see they are the only two asserts which have
side effects.  If you could test a package with this applied I could prepare
one for you, too.

Thanks

----- Forwarded message from Gabriel Filion <lelu...@gmail.com> -----

From: Gabriel Filion <lelu...@gmail.com>
Subject: Re: bup: breaks if PYTHONOPTIMIZE is set (reported in Debian) [PATCH]
Date: Thu, 17 May 2012 06:02:31 -0400
To: Jon Dowland <j...@debian.org>
CC: bup-list <bup-l...@googlegroups.com>
X-CRM114-Status: GOOD (  11.95  )

Hello,

On 12-05-16 10:52 AM, Jon Dowland wrote:
> From e6e39056c3a17db2cd493d5c590f42a8c02ca772 Mon Sep 17 00:00:00 2001
> From: Jon Dowland <j...@debian.org>
> 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.

I didn't confirm that this has the expected result, but it looks reasonable.

Can someone confirm that with this patch, the bug related to
PYTHONOPTIMIZE is fixed?


>  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()

-- 
Gabriel Filion


----- End forwarded message -----
>From e6e39056c3a17db2cd493d5c590f42a8c02ca772 Mon Sep 17 00:00:00 2001
From: Jon Dowland <j...@debian.org>
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()
-- 
1.7.10

Reply via email to