[pypy-commit] pypy translation-cleanup: Inline _exception_getclass() into FSException.

rlamy noreply at buildbot.pypy.org
Sat Sep 22 15:59:15 CEST 2012


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: translation-cleanup
Changeset: r57474:3be388a71ef5
Date: 2012-09-22 02:14 +0100
http://bitbucket.org/pypy/pypy/changeset/3be388a71ef5/

Log:	Inline _exception_getclass() into FSException.

	Since space.exception_is_valid_class_w() is always true in flow
	space, <FSException>._exception_getclass(space, w_inst) is
	equivalent to space.type(w_inst).

	+ make ObjSpace.exception_is_valid_class_w() independent of flow
	space

diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -205,11 +205,11 @@
     def int_w(self, space):
         raise OperationError(space.w_TypeError,
                              typed_unwrap_error_msg(space, "integer", self))
-    
+
     def uint_w(self, space):
         raise OperationError(space.w_TypeError,
                              typed_unwrap_error_msg(space, "integer", self))
-    
+
     def bigint_w(self, space):
         raise OperationError(space.w_TypeError,
                              typed_unwrap_error_msg(space, "integer", self))
@@ -1107,8 +1107,6 @@
         return self.is_true(self.issubtype(w_obj, self.w_BaseException))
 
     def exception_is_valid_class_w(self, w_cls):
-        if not self.full_exceptions:
-            return True
         return self.is_true(self.issubtype(w_cls, self.w_BaseException))
 
     def exception_getclass(self, w_obj):
@@ -1359,7 +1357,7 @@
         if not self.is_true(self.isinstance(w_obj, self.w_str)):
             raise OperationError(self.w_TypeError,
                                  self.wrap('argument must be a string'))
-        return self.str_w(w_obj)            
+        return self.str_w(w_obj)
 
     def unicode_w(self, w_obj):
         return w_obj.unicode_w(self)
@@ -1680,7 +1678,7 @@
     'ValueError',
     'ZeroDivisionError',
     ]
-    
+
 if sys.platform.startswith("win"):
     ObjSpace.ExceptionTable += ['WindowsError']
 
diff --git a/pypy/objspace/flow/flowcontext.py b/pypy/objspace/flow/flowcontext.py
--- a/pypy/objspace/flow/flowcontext.py
+++ b/pypy/objspace/flow/flowcontext.py
@@ -1,7 +1,7 @@
 import collections
 import sys
 from pypy.tool.error import source_lines
-from pypy.interpreter.error import OperationError
+from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.interpreter.pytraceback import PyTraceback
 from pypy.interpreter import pyframe
 from pypy.interpreter.nestedscope import Cell
@@ -55,21 +55,21 @@
             if space.is_w(w_value, space.w_None):
                 # raise Type: we assume we have to instantiate Type
                 w_value = space.call_function(w_type)
-                w_type = self._exception_getclass(space, w_value)
+                w_type = space.type(w_value)
             else:
-                w_valuetype = space.exception_getclass(w_value)
+                w_valuetype = space.type(w_value)
                 if space.exception_issubclass_w(w_valuetype, w_type):
                     # raise Type, Instance: let etype be the exact type of value
                     w_type = w_valuetype
                 else:
                     # raise Type, X: assume X is the constructor argument
                     w_value = space.call_function(w_type, w_value)
-                    w_type = self._exception_getclass(space, w_value)
+                    w_type = space.type(w_value)
 
         else:
             # the only case left here is (inst, None), from a 'raise inst'.
             w_inst = w_type
-            w_instclass = self._exception_getclass(space, w_inst)
+            w_instclass = space.type(w_inst)
             if not space.is_w(w_value, space.w_None):
                 raise FSException(space.w_TypeError,
                                      space.wrap("instance exception may not "


More information about the pypy-commit mailing list