[pypy-svn] r46900 - in pypy/dist/pypy/translator/backendopt: . test
antocuni at codespeak.net
antocuni at codespeak.net
Wed Sep 26 16:20:15 CEST 2007
Author: antocuni
Date: Wed Sep 26 16:20:13 2007
New Revision: 46900
Modified:
pypy/dist/pypy/translator/backendopt/graphanalyze.py
pypy/dist/pypy/translator/backendopt/test/test_canraise.py
Log:
don't crash when trying to analyze recursive methods
Modified: pypy/dist/pypy/translator/backendopt/graphanalyze.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/graphanalyze.py (original)
+++ pypy/dist/pypy/translator/backendopt/graphanalyze.py Wed Sep 26 16:20:13 2007
@@ -48,7 +48,7 @@
graph = getattr(meth, 'graph', None)
if graph is None:
return self.analyze_external_method(op, TYPE, meth)
- return self.analyze_oosend(TYPE, name, seen=None)
+ return self.analyze_oosend(TYPE, name, seen)
if self.operation_is_true(op):
return True
Modified: pypy/dist/pypy/translator/backendopt/test/test_canraise.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/test/test_canraise.py (original)
+++ pypy/dist/pypy/translator/backendopt/test/test_canraise.py Wed Sep 26 16:20:13 2007
@@ -111,6 +111,26 @@
assert not ra.can_raise(op_call_f)
assert ra.can_raise(op_call_m)
+ def test_method_recursive(self):
+ class A:
+ def m(self, x):
+ if x > 0:
+ return self.m(x-1)
+ else:
+ return 42
+ def m(a):
+ return a.m(2)
+ def h():
+ obj = A()
+ m(obj)
+ t, ra = self.translate(h, [])
+ hgraph = graphof(t, h)
+ # fiiiish :-(
+ block = hgraph.startblock
+ op_call_m = block.operations[-1]
+ assert op_call_m.opname == "direct_call"
+ assert not ra.can_raise(op_call_m)
+
def test_instantiate(self):
# instantiate is interesting, because it leads to one of the few cases of
# an indirect call without a list of graphs
More information about the pypy-svn
mailing list