[pypy-svn] r17299 - in pypy/dist/pypy/rpython: . test
arigo at codespeak.net
arigo at codespeak.net
Tue Sep 6 19:36:24 CEST 2005
Author: arigo
Date: Tue Sep 6 19:36:23 2005
New Revision: 17299
Modified:
pypy/dist/pypy/rpython/rtyper.py
pypy/dist/pypy/rpython/test/test_rlist.py
Log:
Fix in the logic of has_implicit_exception(), as found by Christian.
Added a test that shows the problem (and that should have been written
a long time ago anyway, it's not some dark corner).
Modified: pypy/dist/pypy/rpython/rtyper.py
==============================================================================
--- pypy/dist/pypy/rpython/rtyper.py (original)
+++ pypy/dist/pypy/rpython/rtyper.py Tue Sep 6 19:36:23 2005
@@ -630,11 +630,14 @@
# high-level ops before the last one in the block
if self.llops.implicit_exceptions_checked is None:
self.llops.implicit_exceptions_checked = []
+ result = False
for link in self.exceptionlinks:
if issubclass(exc_cls, link.exitcase):
self.llops.implicit_exceptions_checked.append(link.exitcase)
- return True
- return False
+ result = True
+ # go on looping to add possibly more exceptions to the list
+ # (e.g. Exception itself - see test_rlist.test_valueerror)
+ return result
def exception_is_here(self):
if self.llops.llop_raising_exceptions is not None:
Modified: pypy/dist/pypy/rpython/test/test_rlist.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rlist.py (original)
+++ pypy/dist/pypy/rpython/test/test_rlist.py Tue Sep 6 19:36:23 2005
@@ -464,3 +464,20 @@
for j in range(6):
res = interpret(list_basic_ops, [i, j])
assert res == list_basic_ops(i, j)
+
+def test_valueerror():
+ def fn(i):
+ l = [4, 7, 3]
+ try:
+ j = l.index(i)
+ except ValueError:
+ j = 100
+ return j
+ res = interpret(fn, [4])
+ assert res == 0
+ res = interpret(fn, [7])
+ assert res == 1
+ res = interpret(fn, [3])
+ assert res == 2
+ res = interpret(fn, [6])
+ assert res == 100
More information about the Pypy-commit
mailing list