[pypy-commit] benchmarks default: Under some unknown circumstance, it is possible to hit a path where a Branch instance

arigo noreply at buildbot.pypy.org
Tue May 26 21:38:02 CEST 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r326:bfc5304e5a50
Date: 2015-05-26 21:38 +0200
http://bitbucket.org/pypy/benchmarks/changeset/bfc5304e5a50/

Log:	Under some unknown circumstance, it is possible to hit a path where
	a Branch instance doesn't have a "lineno" attribute, but we try to
	read it anyway. I've given up trying to figure out why it seems to
	occur (rarely) on top of PyPy but (apparently) not on top of
	CPython. Instead, always stick lineno and col_offset attributes,
	defaulting to 0.

diff --git a/own/icbd/icbd/util/cfa.py b/own/icbd/icbd/util/cfa.py
--- a/own/icbd/icbd/util/cfa.py
+++ b/own/icbd/icbd/util/cfa.py
@@ -22,9 +22,8 @@
         self.true_block = None
         self.false_block = None
 
-        if lineno:
-            self.lineno = lineno
-            self.col_offset = 0
+        self.lineno = lineno or 0
+        self.col_offset = 0
 
     def set_true(self, bid):
         assert isinstance(bid, int)
@@ -39,10 +38,8 @@
     def __init__(self, iter, lineno=None, col_offset=None):
         assert isinstance(iter, _ast.AST)
         self.iter = iter
-        if lineno:
-            self.lineno = lineno
-        if col_offset:
-            self.col_offset = col_offset
+        self.lineno = lineno or 0
+        self.col_offset = col_offset or 0
 
 class CFG(object):
     def __init__(self):


More information about the pypy-commit mailing list