[pypy-svn] pypy default: Fix the test in test_exception.py by adding the missing 'can_only_throw'

arigo commits-noreply at bitbucket.org
Tue Feb 15 10:59:24 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r41944:523583dfb09e
Date: 2011-02-15 10:59 +0100
http://bitbucket.org/pypy/pypy/changeset/523583dfb09e/

Log:	Fix the test in test_exception.py by adding the missing
	'can_only_throw' attribute to method_pop(). Similar issues can be
	fixed by adding more 'can_only_throw' to the other method_xxxs().

diff --git a/pypy/annotation/unaryop.py b/pypy/annotation/unaryop.py
--- a/pypy/annotation/unaryop.py
+++ b/pypy/annotation/unaryop.py
@@ -303,6 +303,7 @@
     def method_pop(lst, s_index=None):
         lst.listdef.resize()
         return lst.listdef.read_item()
+    method_pop.can_only_throw = [IndexError]
 
     def method_index(lst, s_value):
         getbookkeeper().count("list_index")
@@ -642,6 +643,11 @@
 
 
 class __extend__(SomeBuiltin):
+    def _can_only_throw(bltn, *args):
+        analyser_func = getattr(bltn.analyser, 'im_func', None)
+        can_only_throw = getattr(analyser_func, 'can_only_throw', None)
+        return can_only_throw   # or None to mean "anything"
+
     def simple_call(bltn, *args):
         if bltn.s_self is not None:
             return bltn.analyser(bltn.s_self, *args)
@@ -649,6 +655,7 @@
             if bltn.methodname:
                 getbookkeeper().count(bltn.methodname.replace('.', '_'), *args)
             return bltn.analyser(*args)
+    simple_call.can_only_throw = _can_only_throw
 
     def call(bltn, args, implicit_init=False):
         args_s, kwds = args.unpack()

diff --git a/.hgsubstate b/.hgsubstate
--- a/.hgsubstate
+++ b/.hgsubstate
@@ -1,3 +1,3 @@
 80037 greenlet
-80345 lib_pypy/pyrepl
+80037 lib_pypy/pyrepl
 80037 testrunner

diff --git a/pypy/rpython/test/test_exception.py b/pypy/rpython/test/test_exception.py
--- a/pypy/rpython/test/test_exception.py
+++ b/pypy/rpython/test/test_exception.py
@@ -125,7 +125,6 @@
         assert res == 11
 
     def test_pop_inside_try(self):
-        py.test.skip('fixme!')
         class MyException(Exception):
             pass
         def f(n):


More information about the Pypy-commit mailing list