[pypy-svn] r35338 - in pypy/dist/pypy: annotation rpython rpython/test
arigo at codespeak.net
arigo at codespeak.net
Tue Dec 5 21:50:42 CET 2006
Author: arigo
Date: Tue Dec 5 21:50:39 2006
New Revision: 35338
Modified:
pypy/dist/pypy/annotation/annrpython.py
pypy/dist/pypy/rpython/robject.py
pypy/dist/pypy/rpython/test/test_exception.py
Log:
(pedronis, arigo)
Two more test cases and fixes for annotating exception blocks. Urgh.
Modified: pypy/dist/pypy/annotation/annrpython.py
==============================================================================
--- pypy/dist/pypy/annotation/annrpython.py (original)
+++ pypy/dist/pypy/annotation/annrpython.py Tue Dec 5 21:50:39 2006
@@ -614,7 +614,6 @@
candidates = [c for c in candidates if c not in covered]
for link in exits:
- self.links_followed[link] = True
import types
in_except_block = False
@@ -695,7 +694,12 @@
if in_except_block:
last_exception_object.is_type_of = last_exc_value_vars
+ if annmodel.s_ImpossibleValue in cells:
+ continue # ignore links that try to pass impossible values
+
+ self.links_followed[link] = True
self.addpendingblock(graph, link.target, cells)
+
if block in self.notify:
# reflow from certain positions when this block is done
for callback in self.notify[block]:
Modified: pypy/dist/pypy/rpython/robject.py
==============================================================================
--- pypy/dist/pypy/rpython/robject.py (original)
+++ pypy/dist/pypy/rpython/robject.py Tue Dec 5 21:50:39 2006
@@ -9,10 +9,10 @@
class __extend__(annmodel.SomeObject):
def rtyper_makerepr(self, rtyper):
- if self.is_constant():
- return constpyobj_repr
if self.knowntype is type:
return rclass.get_type_repr(rtyper)
+ elif self.is_constant():
+ return constpyobj_repr
else:
return pyobj_repr
def rtyper_makekey(self):
Modified: pypy/dist/pypy/rpython/test/test_exception.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_exception.py (original)
+++ pypy/dist/pypy/rpython/test/test_exception.py Tue Dec 5 21:50:39 2006
@@ -1,6 +1,8 @@
+import py
from pypy.translator.translator import TranslationContext
from pypy.rpython.lltypesystem.lltype import *
from pypy.rpython.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
+from pypy.rpython.llinterp import LLException
class MyException(Exception):
pass
@@ -80,6 +82,38 @@
res = self.interpret(f, [7])
assert res is None
+ def test_raise_and_catch_other(self):
+ class BytecodeCorruption(Exception):
+ pass
+ class OperationError(Exception):
+ def __init__(self, a):
+ self.a = a
+ def f(next_instr):
+ if next_instr < 7:
+ raise OperationError(next_instr)
+ try:
+ raise BytecodeCorruption()
+ except OperationError, operr:
+ next_instr -= operr.a
+ py.test.raises(LLException, self.interpret, f, [10])
+
+ def test_raise_prebuilt_and_catch_other(self):
+ class BytecodeCorruption(Exception):
+ pass
+ class OperationError(Exception):
+ def __init__(self, a):
+ self.a = a
+ bcerr = BytecodeCorruption()
+ def f(next_instr):
+ if next_instr < 7:
+ raise OperationError(next_instr)
+ try:
+ raise bcerr
+ except OperationError, operr:
+ next_instr -= operr.a
+ py.test.raises(LLException, self.interpret, f, [10])
+
+
class TestLLtype(BaseTestException, LLRtypeMixin):
pass
More information about the pypy-svn
mailing list