[pypy-commit] pypy operrfmt-NT: utilize %T everywhere

pjenvey noreply at buildbot.pypy.org
Sun May 26 00:35:53 CEST 2013


Author: Philip Jenvey <pjenvey at underboss.org>
Branch: operrfmt-NT
Changeset: r64562:681043e107df
Date: 2013-05-25 15:32 -0700
http://bitbucket.org/pypy/pypy/changeset/681043e107df/

Log:	utilize %T everywhere

diff too long, truncating to 2000 out of 2206 lines

diff --git a/pypy/interpreter/argument.py b/pypy/interpreter/argument.py
--- a/pypy/interpreter/argument.py
+++ b/pypy/interpreter/argument.py
@@ -86,12 +86,9 @@
             args_w = space.fixedview(w_stararg)
         except OperationError, e:
             if e.match(space, space.w_TypeError):
-                w_type = space.type(w_stararg)
-                typename = w_type.getname(space)
-                raise OperationError(
+                raise operationerrfmt(
                     space.w_TypeError,
-                    space.wrap("argument after * must be "
-                               "a sequence, not %s" % (typename,)))
+                    "argument after * must be a sequence, not %T", w_stararg)
             raise
         self.arguments_w = self.arguments_w + args_w
 
@@ -116,12 +113,10 @@
                 w_keys = space.call_method(w_starstararg, "keys")
             except OperationError, e:
                 if e.match(space, space.w_AttributeError):
-                    w_type = space.type(w_starstararg)
-                    typename = w_type.getname(space)
-                    raise OperationError(
+                    raise operationerrfmt(
                         space.w_TypeError,
-                        space.wrap("argument after ** must be "
-                                   "a mapping, not %s" % (typename,)))
+                        "argument after ** must be a mapping, not %T",
+                        w_starstararg)
                 raise
             keys_w = space.unpackiterable(w_keys)
         keywords_w = [None] * len(keys_w)
diff --git a/pypy/interpreter/astcompiler/ast.py b/pypy/interpreter/astcompiler/ast.py
--- a/pypy/interpreter/astcompiler/ast.py
+++ b/pypy/interpreter/astcompiler/ast.py
@@ -2793,8 +2793,7 @@
 
 def Module_get_body(space, w_self):
     if not w_self.initialization_state & 1:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
@@ -2835,8 +2834,7 @@
 
 def Interactive_get_body(space, w_self):
     if not w_self.initialization_state & 1:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
@@ -2881,8 +2879,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 1:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     return space.wrap(w_self.body)
 
 def Expression_set_body(space, w_self, w_new_value):
@@ -2925,8 +2922,7 @@
 
 def Suite_get_body(space, w_self):
     if not w_self.initialization_state & 1:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
@@ -2971,8 +2967,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 1:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'lineno')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'lineno')
     return space.wrap(w_self.lineno)
 
 def stmt_set_lineno(space, w_self, w_new_value):
@@ -2993,8 +2988,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 2:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'col_offset')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'col_offset')
     return space.wrap(w_self.col_offset)
 
 def stmt_set_col_offset(space, w_self, w_new_value):
@@ -3024,8 +3018,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'name')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'name')
     return space.wrap(w_self.name)
 
 def FunctionDef_set_name(space, w_self, w_new_value):
@@ -3046,8 +3039,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'args')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'args')
     return space.wrap(w_self.args)
 
 def FunctionDef_set_args(space, w_self, w_new_value):
@@ -3064,8 +3056,7 @@
 
 def FunctionDef_get_body(space, w_self):
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
@@ -3081,8 +3072,7 @@
 
 def FunctionDef_get_decorator_list(space, w_self):
     if not w_self.initialization_state & 32:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'decorator_list')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'decorator_list')
     if w_self.w_decorator_list is None:
         if w_self.decorator_list is None:
             list_w = []
@@ -3131,8 +3121,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'name')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'name')
     return space.wrap(w_self.name)
 
 def ClassDef_set_name(space, w_self, w_new_value):
@@ -3149,8 +3138,7 @@
 
 def ClassDef_get_bases(space, w_self):
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'bases')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'bases')
     if w_self.w_bases is None:
         if w_self.bases is None:
             list_w = []
@@ -3166,8 +3154,7 @@
 
 def ClassDef_get_body(space, w_self):
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
@@ -3183,8 +3170,7 @@
 
 def ClassDef_get_decorator_list(space, w_self):
     if not w_self.initialization_state & 32:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'decorator_list')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'decorator_list')
     if w_self.w_decorator_list is None:
         if w_self.decorator_list is None:
             list_w = []
@@ -3234,8 +3220,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
     return space.wrap(w_self.value)
 
 def Return_set_value(space, w_self, w_new_value):
@@ -3278,8 +3263,7 @@
 
 def Delete_get_targets(space, w_self):
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'targets')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'targets')
     if w_self.w_targets is None:
         if w_self.targets is None:
             list_w = []
@@ -3320,8 +3304,7 @@
 
 def Assign_get_targets(space, w_self):
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'targets')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'targets')
     if w_self.w_targets is None:
         if w_self.targets is None:
             list_w = []
@@ -3341,8 +3324,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
     return space.wrap(w_self.value)
 
 def Assign_set_value(space, w_self, w_new_value):
@@ -3391,8 +3373,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'target')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'target')
     return space.wrap(w_self.target)
 
 def AugAssign_set_target(space, w_self, w_new_value):
@@ -3415,8 +3396,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'op')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'op')
     return operator_to_class[w_self.op - 1]()
 
 def AugAssign_set_op(space, w_self, w_new_value):
@@ -3439,8 +3419,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
     return space.wrap(w_self.value)
 
 def AugAssign_set_value(space, w_self, w_new_value):
@@ -3489,8 +3468,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'dest')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'dest')
     return space.wrap(w_self.dest)
 
 def Print_set_dest(space, w_self, w_new_value):
@@ -3509,8 +3487,7 @@
 
 def Print_get_values(space, w_self):
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'values')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'values')
     if w_self.w_values is None:
         if w_self.values is None:
             list_w = []
@@ -3530,8 +3507,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'nl')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'nl')
     return space.wrap(w_self.nl)
 
 def Print_set_nl(space, w_self, w_new_value):
@@ -3579,8 +3555,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'target')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'target')
     return space.wrap(w_self.target)
 
 def For_set_target(space, w_self, w_new_value):
@@ -3603,8 +3578,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'iter')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'iter')
     return space.wrap(w_self.iter)
 
 def For_set_iter(space, w_self, w_new_value):
@@ -3623,8 +3597,7 @@
 
 def For_get_body(space, w_self):
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
@@ -3640,8 +3613,7 @@
 
 def For_get_orelse(space, w_self):
     if not w_self.initialization_state & 32:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'orelse')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'orelse')
     if w_self.w_orelse is None:
         if w_self.orelse is None:
             list_w = []
@@ -3690,8 +3662,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'test')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'test')
     return space.wrap(w_self.test)
 
 def While_set_test(space, w_self, w_new_value):
@@ -3710,8 +3681,7 @@
 
 def While_get_body(space, w_self):
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
@@ -3727,8 +3697,7 @@
 
 def While_get_orelse(space, w_self):
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'orelse')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'orelse')
     if w_self.w_orelse is None:
         if w_self.orelse is None:
             list_w = []
@@ -3776,8 +3745,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'test')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'test')
     return space.wrap(w_self.test)
 
 def If_set_test(space, w_self, w_new_value):
@@ -3796,8 +3764,7 @@
 
 def If_get_body(space, w_self):
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
@@ -3813,8 +3780,7 @@
 
 def If_get_orelse(space, w_self):
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'orelse')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'orelse')
     if w_self.w_orelse is None:
         if w_self.orelse is None:
             list_w = []
@@ -3862,8 +3828,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'context_expr')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'context_expr')
     return space.wrap(w_self.context_expr)
 
 def With_set_context_expr(space, w_self, w_new_value):
@@ -3886,8 +3851,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'optional_vars')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'optional_vars')
     return space.wrap(w_self.optional_vars)
 
 def With_set_optional_vars(space, w_self, w_new_value):
@@ -3906,8 +3870,7 @@
 
 def With_get_body(space, w_self):
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
@@ -3954,8 +3917,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'type')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'type')
     return space.wrap(w_self.type)
 
 def Raise_set_type(space, w_self, w_new_value):
@@ -3978,8 +3940,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'inst')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'inst')
     return space.wrap(w_self.inst)
 
 def Raise_set_inst(space, w_self, w_new_value):
@@ -4002,8 +3963,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'tback')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'tback')
     return space.wrap(w_self.tback)
 
 def Raise_set_tback(space, w_self, w_new_value):
@@ -4048,8 +4008,7 @@
 
 def TryExcept_get_body(space, w_self):
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
@@ -4065,8 +4024,7 @@
 
 def TryExcept_get_handlers(space, w_self):
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'handlers')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'handlers')
     if w_self.w_handlers is None:
         if w_self.handlers is None:
             list_w = []
@@ -4082,8 +4040,7 @@
 
 def TryExcept_get_orelse(space, w_self):
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'orelse')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'orelse')
     if w_self.w_orelse is None:
         if w_self.orelse is None:
             list_w = []
@@ -4128,8 +4085,7 @@
 
 def TryFinally_get_body(space, w_self):
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
@@ -4145,8 +4101,7 @@
 
 def TryFinally_get_finalbody(space, w_self):
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'finalbody')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'finalbody')
     if w_self.w_finalbody is None:
         if w_self.finalbody is None:
             list_w = []
@@ -4193,8 +4148,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'test')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'test')
     return space.wrap(w_self.test)
 
 def Assert_set_test(space, w_self, w_new_value):
@@ -4217,8 +4171,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'msg')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'msg')
     return space.wrap(w_self.msg)
 
 def Assert_set_msg(space, w_self, w_new_value):
@@ -4262,8 +4215,7 @@
 
 def Import_get_names(space, w_self):
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'names')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'names')
     if w_self.w_names is None:
         if w_self.names is None:
             list_w = []
@@ -4308,8 +4260,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'module')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'module')
     return space.wrap(w_self.module)
 
 def ImportFrom_set_module(space, w_self, w_new_value):
@@ -4329,8 +4280,7 @@
 
 def ImportFrom_get_names(space, w_self):
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'names')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'names')
     if w_self.w_names is None:
         if w_self.names is None:
             list_w = []
@@ -4350,8 +4300,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'level')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'level')
     return space.wrap(w_self.level)
 
 def ImportFrom_set_level(space, w_self, w_new_value):
@@ -4399,8 +4348,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     return space.wrap(w_self.body)
 
 def Exec_set_body(space, w_self, w_new_value):
@@ -4423,8 +4371,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'globals')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'globals')
     return space.wrap(w_self.globals)
 
 def Exec_set_globals(space, w_self, w_new_value):
@@ -4447,8 +4394,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'locals')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'locals')
     return space.wrap(w_self.locals)
 
 def Exec_set_locals(space, w_self, w_new_value):
@@ -4493,8 +4439,7 @@
 
 def Global_get_names(space, w_self):
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'names')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'names')
     if w_self.w_names is None:
         if w_self.names is None:
             list_w = []
@@ -4539,8 +4484,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
     return space.wrap(w_self.value)
 
 def Expr_set_value(space, w_self, w_new_value):
@@ -4638,8 +4582,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 1:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'lineno')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'lineno')
     return space.wrap(w_self.lineno)
 
 def expr_set_lineno(space, w_self, w_new_value):
@@ -4660,8 +4603,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 2:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'col_offset')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'col_offset')
     return space.wrap(w_self.col_offset)
 
 def expr_set_col_offset(space, w_self, w_new_value):
@@ -4691,8 +4633,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'op')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'op')
     return boolop_to_class[w_self.op - 1]()
 
 def BoolOp_set_op(space, w_self, w_new_value):
@@ -4711,8 +4652,7 @@
 
 def BoolOp_get_values(space, w_self):
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'values')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'values')
     if w_self.w_values is None:
         if w_self.values is None:
             list_w = []
@@ -4758,8 +4698,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'left')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'left')
     return space.wrap(w_self.left)
 
 def BinOp_set_left(space, w_self, w_new_value):
@@ -4782,8 +4721,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'op')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'op')
     return operator_to_class[w_self.op - 1]()
 
 def BinOp_set_op(space, w_self, w_new_value):
@@ -4806,8 +4744,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'right')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'right')
     return space.wrap(w_self.right)
 
 def BinOp_set_right(space, w_self, w_new_value):
@@ -4856,8 +4793,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'op')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'op')
     return unaryop_to_class[w_self.op - 1]()
 
 def UnaryOp_set_op(space, w_self, w_new_value):
@@ -4880,8 +4816,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'operand')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'operand')
     return space.wrap(w_self.operand)
 
 def UnaryOp_set_operand(space, w_self, w_new_value):
@@ -4929,8 +4864,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'args')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'args')
     return space.wrap(w_self.args)
 
 def Lambda_set_args(space, w_self, w_new_value):
@@ -4951,8 +4885,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     return space.wrap(w_self.body)
 
 def Lambda_set_body(space, w_self, w_new_value):
@@ -5000,8 +4933,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'test')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'test')
     return space.wrap(w_self.test)
 
 def IfExp_set_test(space, w_self, w_new_value):
@@ -5024,8 +4956,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     return space.wrap(w_self.body)
 
 def IfExp_set_body(space, w_self, w_new_value):
@@ -5048,8 +4979,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'orelse')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'orelse')
     return space.wrap(w_self.orelse)
 
 def IfExp_set_orelse(space, w_self, w_new_value):
@@ -5094,8 +5024,7 @@
 
 def Dict_get_keys(space, w_self):
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'keys')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'keys')
     if w_self.w_keys is None:
         if w_self.keys is None:
             list_w = []
@@ -5111,8 +5040,7 @@
 
 def Dict_get_values(space, w_self):
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'values')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'values')
     if w_self.w_values is None:
         if w_self.values is None:
             list_w = []
@@ -5155,8 +5083,7 @@
 
 def Set_get_elts(space, w_self):
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'elts')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'elts')
     if w_self.w_elts is None:
         if w_self.elts is None:
             list_w = []
@@ -5201,8 +5128,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'elt')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'elt')
     return space.wrap(w_self.elt)
 
 def ListComp_set_elt(space, w_self, w_new_value):
@@ -5221,8 +5147,7 @@
 
 def ListComp_get_generators(space, w_self):
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'generators')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'generators')
     if w_self.w_generators is None:
         if w_self.generators is None:
             list_w = []
@@ -5268,8 +5193,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'elt')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'elt')
     return space.wrap(w_self.elt)
 
 def SetComp_set_elt(space, w_self, w_new_value):
@@ -5288,8 +5212,7 @@
 
 def SetComp_get_generators(space, w_self):
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'generators')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'generators')
     if w_self.w_generators is None:
         if w_self.generators is None:
             list_w = []
@@ -5335,8 +5258,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'key')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'key')
     return space.wrap(w_self.key)
 
 def DictComp_set_key(space, w_self, w_new_value):
@@ -5359,8 +5281,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
     return space.wrap(w_self.value)
 
 def DictComp_set_value(space, w_self, w_new_value):
@@ -5379,8 +5300,7 @@
 
 def DictComp_get_generators(space, w_self):
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'generators')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'generators')
     if w_self.w_generators is None:
         if w_self.generators is None:
             list_w = []
@@ -5427,8 +5347,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'elt')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'elt')
     return space.wrap(w_self.elt)
 
 def GeneratorExp_set_elt(space, w_self, w_new_value):
@@ -5447,8 +5366,7 @@
 
 def GeneratorExp_get_generators(space, w_self):
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'generators')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'generators')
     if w_self.w_generators is None:
         if w_self.generators is None:
             list_w = []
@@ -5494,8 +5412,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
     return space.wrap(w_self.value)
 
 def Yield_set_value(space, w_self, w_new_value):
@@ -5542,8 +5459,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'left')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'left')
     return space.wrap(w_self.left)
 
 def Compare_set_left(space, w_self, w_new_value):
@@ -5562,8 +5478,7 @@
 
 def Compare_get_ops(space, w_self):
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'ops')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'ops')
     if w_self.w_ops is None:
         if w_self.ops is None:
             list_w = []
@@ -5579,8 +5494,7 @@
 
 def Compare_get_comparators(space, w_self):
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'comparators')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'comparators')
     if w_self.w_comparators is None:
         if w_self.comparators is None:
             list_w = []
@@ -5628,8 +5542,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'func')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'func')
     return space.wrap(w_self.func)
 
 def Call_set_func(space, w_self, w_new_value):
@@ -5648,8 +5561,7 @@
 
 def Call_get_args(space, w_self):
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'args')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'args')
     if w_self.w_args is None:
         if w_self.args is None:
             list_w = []
@@ -5665,8 +5577,7 @@
 
 def Call_get_keywords(space, w_self):
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'keywords')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'keywords')
     if w_self.w_keywords is None:
         if w_self.keywords is None:
             list_w = []
@@ -5686,8 +5597,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 32:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'starargs')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'starargs')
     return space.wrap(w_self.starargs)
 
 def Call_set_starargs(space, w_self, w_new_value):
@@ -5710,8 +5620,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 64:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'kwargs')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'kwargs')
     return space.wrap(w_self.kwargs)
 
 def Call_set_kwargs(space, w_self, w_new_value):
@@ -5764,8 +5673,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
     return space.wrap(w_self.value)
 
 def Repr_set_value(space, w_self, w_new_value):
@@ -5812,8 +5720,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'n')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'n')
     return w_self.n
 
 def Num_set_n(space, w_self, w_new_value):
@@ -5858,8 +5765,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 's')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 's')
     return w_self.s
 
 def Str_set_s(space, w_self, w_new_value):
@@ -5904,8 +5810,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
     return space.wrap(w_self.value)
 
 def Attribute_set_value(space, w_self, w_new_value):
@@ -5928,8 +5833,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'attr')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'attr')
     return space.wrap(w_self.attr)
 
 def Attribute_set_attr(space, w_self, w_new_value):
@@ -5950,8 +5854,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'ctx')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'ctx')
     return expr_context_to_class[w_self.ctx - 1]()
 
 def Attribute_set_ctx(space, w_self, w_new_value):
@@ -6000,8 +5903,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
     return space.wrap(w_self.value)
 
 def Subscript_set_value(space, w_self, w_new_value):
@@ -6024,8 +5926,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'slice')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'slice')
     return space.wrap(w_self.slice)
 
 def Subscript_set_slice(space, w_self, w_new_value):
@@ -6048,8 +5949,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'ctx')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'ctx')
     return expr_context_to_class[w_self.ctx - 1]()
 
 def Subscript_set_ctx(space, w_self, w_new_value):
@@ -6098,8 +5998,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'id')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'id')
     return space.wrap(w_self.id)
 
 def Name_set_id(space, w_self, w_new_value):
@@ -6120,8 +6019,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'ctx')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'ctx')
     return expr_context_to_class[w_self.ctx - 1]()
 
 def Name_set_ctx(space, w_self, w_new_value):
@@ -6165,8 +6063,7 @@
 
 def List_get_elts(space, w_self):
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'elts')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'elts')
     if w_self.w_elts is None:
         if w_self.elts is None:
             list_w = []
@@ -6186,8 +6083,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'ctx')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'ctx')
     return expr_context_to_class[w_self.ctx - 1]()
 
 def List_set_ctx(space, w_self, w_new_value):
@@ -6232,8 +6128,7 @@
 
 def Tuple_get_elts(space, w_self):
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'elts')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'elts')
     if w_self.w_elts is None:
         if w_self.elts is None:
             list_w = []
@@ -6253,8 +6148,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'ctx')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'ctx')
     return expr_context_to_class[w_self.ctx - 1]()
 
 def Tuple_set_ctx(space, w_self, w_new_value):
@@ -6303,8 +6197,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
     return w_self.value
 
 def Const_set_value(space, w_self, w_new_value):
@@ -6422,8 +6315,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 1:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'lower')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'lower')
     return space.wrap(w_self.lower)
 
 def Slice_set_lower(space, w_self, w_new_value):
@@ -6446,8 +6338,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 2:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'upper')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'upper')
     return space.wrap(w_self.upper)
 
 def Slice_set_upper(space, w_self, w_new_value):
@@ -6470,8 +6361,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'step')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'step')
     return space.wrap(w_self.step)
 
 def Slice_set_step(space, w_self, w_new_value):
@@ -6516,8 +6406,7 @@
 
 def ExtSlice_get_dims(space, w_self):
     if not w_self.initialization_state & 1:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'dims')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'dims')
     if w_self.w_dims is None:
         if w_self.dims is None:
             list_w = []
@@ -6562,8 +6451,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 1:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
     return space.wrap(w_self.value)
 
 def Index_set_value(space, w_self, w_new_value):
@@ -6834,8 +6722,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 1:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'target')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'target')
     return space.wrap(w_self.target)
 
 def comprehension_set_target(space, w_self, w_new_value):
@@ -6858,8 +6745,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 2:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'iter')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'iter')
     return space.wrap(w_self.iter)
 
 def comprehension_set_iter(space, w_self, w_new_value):
@@ -6878,8 +6764,7 @@
 
 def comprehension_get_ifs(space, w_self):
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'ifs')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'ifs')
     if w_self.w_ifs is None:
         if w_self.ifs is None:
             list_w = []
@@ -6926,8 +6811,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 1:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'lineno')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'lineno')
     return space.wrap(w_self.lineno)
 
 def excepthandler_set_lineno(space, w_self, w_new_value):
@@ -6948,8 +6832,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 2:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'col_offset')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'col_offset')
     return space.wrap(w_self.col_offset)
 
 def excepthandler_set_col_offset(space, w_self, w_new_value):
@@ -6979,8 +6862,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'type')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'type')
     return space.wrap(w_self.type)
 
 def ExceptHandler_set_type(space, w_self, w_new_value):
@@ -7003,8 +6885,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'name')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'name')
     return space.wrap(w_self.name)
 
 def ExceptHandler_set_name(space, w_self, w_new_value):
@@ -7023,8 +6904,7 @@
 
 def ExceptHandler_get_body(space, w_self):
     if not w_self.initialization_state & 16:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
@@ -7067,8 +6947,7 @@
 
 def arguments_get_args(space, w_self):
     if not w_self.initialization_state & 1:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'args')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'args')
     if w_self.w_args is None:
         if w_self.args is None:
             list_w = []
@@ -7088,8 +6967,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 2:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'vararg')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'vararg')
     return space.wrap(w_self.vararg)
 
 def arguments_set_vararg(space, w_self, w_new_value):
@@ -7113,8 +6991,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'kwarg')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'kwarg')
     return space.wrap(w_self.kwarg)
 
 def arguments_set_kwarg(space, w_self, w_new_value):
@@ -7134,8 +7011,7 @@
 
 def arguments_get_defaults(space, w_self):
     if not w_self.initialization_state & 8:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'defaults')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'defaults')
     if w_self.w_defaults is None:
         if w_self.defaults is None:
             list_w = []
@@ -7184,8 +7060,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 1:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'arg')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'arg')
     return space.wrap(w_self.arg)
 
 def keyword_set_arg(space, w_self, w_new_value):
@@ -7206,8 +7081,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 2:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
     return space.wrap(w_self.value)
 
 def keyword_set_value(space, w_self, w_new_value):
@@ -7255,8 +7129,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 1:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'name')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'name')
     return space.wrap(w_self.name)
 
 def alias_set_name(space, w_self, w_new_value):
@@ -7277,8 +7150,7 @@
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 2:
-        typename = space.type(w_self).getname(space)
-        raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'asname')
+        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'asname')
     return space.wrap(w_self.asname)
 
 def alias_set_asname(space, w_self, w_new_value):
diff --git a/pypy/interpreter/astcompiler/tools/asdl_py.py b/pypy/interpreter/astcompiler/tools/asdl_py.py
--- a/pypy/interpreter/astcompiler/tools/asdl_py.py
+++ b/pypy/interpreter/astcompiler/tools/asdl_py.py
@@ -409,8 +409,7 @@
             self.emit("    if w_obj is not None:", 1)
             self.emit("        return w_obj", 1)
         self.emit("if not w_self.initialization_state & %s:" % (flag,), 1)
-        self.emit("typename = space.type(w_self).getname(space)", 2)
-        self.emit("raise operationerrfmt(space.w_AttributeError, \"'%%s' object has no attribute '%%s'\", typename, '%s')" %
+        self.emit("raise operationerrfmt(space.w_AttributeError, \"'%%T' object has no attribute '%%s'\", w_self, '%s')" %
                   (field.name,), 2)
         if field.seq:
             self.emit("if w_self.w_%s is None:" % (field.name,), 1)
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -61,10 +61,9 @@
         return False
 
     def setdict(self, space, w_dict):
-        typename = space.type(self).getname(space)
         raise operationerrfmt(space.w_TypeError,
-                              "attribute '__dict__' of %s objects "
-                              "is not writable", typename)
+                              "attribute '__dict__' of %T objects "
+                              "is not writable", self)
 
     # to be used directly only by space.type implementations
     def getclass(self, space):
@@ -124,9 +123,8 @@
             classname = '?'
         else:
             classname = wrappable_class_name(RequiredClass)
-        msg = "'%s' object expected, got '%s' instead"
-        raise operationerrfmt(space.w_TypeError, msg,
-            classname, self.getclass(space).getname(space))
+        msg = "'%s' object expected, got '%T' instead"
+        raise operationerrfmt(space.w_TypeError, msg, classname, self)
 
     # used by _weakref implemenation
 
@@ -134,9 +132,8 @@
         return None
 
     def setweakref(self, space, weakreflifeline):
-        typename = space.type(self).getname(space)
         raise operationerrfmt(space.w_TypeError,
-            "cannot create weak reference to '%s' object", typename)
+            "cannot create weak reference to '%T' object", self)
 
     def delweakref(self):
         pass
@@ -226,18 +223,15 @@
     def int(self, space):
         w_impl = space.lookup(self, '__int__')
         if w_impl is None:
-            typename = space.type(self).getname(space)
             raise operationerrfmt(space.w_TypeError,
-                  "unsupported operand type for int(): '%s'",
-                                  typename)
+                  "unsupported operand type for int(): '%T'", self)
         w_result = space.get_and_call_function(w_impl, self)
 
         if (space.isinstance_w(w_result, space.w_int) or
             space.isinstance_w(w_result, space.w_long)):
             return w_result
-        typename = space.type(w_result).getname(space)
-        msg = "__int__ returned non-int (type '%s')"
-        raise operationerrfmt(space.w_TypeError, msg, typename)
+        msg = "__int__ returned non-int (type '%T')"
+        raise operationerrfmt(space.w_TypeError, msg, w_result)
 
     def __spacebind__(self, space):
         return self
@@ -749,10 +743,9 @@
         if can_be_None and self.is_none(w_obj):
             return None
         if not isinstance(w_obj, RequiredClass):   # or obj is None
-            msg = "'%s' object expected, got '%s' instead"
+            msg = "'%s' object expected, got '%T' instead"
             raise operationerrfmt(self.w_TypeError, msg,
-                wrappable_class_name(RequiredClass),
-                w_obj.getclass(self).getname(self))
+                wrappable_class_name(RequiredClass), w_obj)
         return w_obj
     interp_w._annspecialcase_ = 'specialize:arg(1)'
 
@@ -1221,9 +1214,8 @@
         except OperationError, err:
             if objdescr is None or not err.match(self, self.w_TypeError):
                 raise
-            msg = "%s must be an integer, not %s"
-            raise operationerrfmt(self.w_TypeError, msg,
-                objdescr, self.type(w_obj).getname(self))
+            msg = "%s must be an integer, not %T"
+            raise operationerrfmt(self.w_TypeError, msg, objdescr, w_obj)
         try:
             index = self.int_w(w_index)
         except OperationError, err:
@@ -1237,9 +1229,8 @@
                     return sys.maxint
             else:
                 raise operationerrfmt(
-                    w_exception,
-                    "cannot fit '%s' into an index-sized "
-                    "integer", self.type(w_obj).getname(self))
+                    w_exception, "cannot fit '%T' into an index-sized integer",
+                    w_obj)
         else:
             return index
 
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -915,10 +915,9 @@
         w_enter = self.space.lookup(w_manager, "__enter__")
         w_descr = self.space.lookup(w_manager, "__exit__")
         if w_enter is None or w_descr is None:
-            typename = self.space.type(w_manager).getname(self.space)
             raise operationerrfmt(self.space.w_AttributeError,
-                "'%s' object is not a context manager"
-                " (no __enter__/__exit__ method)", typename)
+                "'%T' object is not a context manager"
+                " (no __enter__/__exit__ method)", w_manager)
         w_exit = self.space.get(w_descr, w_manager)
         self.settopvalue(w_exit)
         w_result = self.space.get_and_call_function(w_enter, w_manager)
diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py
--- a/pypy/interpreter/typedef.py
+++ b/pypy/interpreter/typedef.py
@@ -553,12 +553,9 @@
 
     def typecheck(self, space, w_obj):
         if not space.isinstance_w(w_obj, self.w_cls):
-            raise operationerrfmt(space.w_TypeError,
-                                  "descriptor '%s' for '%s'"
-                                  " objects doesn't apply to '%s' object",
-                                  self.name,
-                                  self.w_cls.name,
-                                  space.type(w_obj).getname(space))
+            m = "descriptor '%s' for '%s' objects doesn't apply to '%T' object"
+            raise operationerrfmt(space.w_TypeError, m,
+                                  self.name, self.w_cls.name, w_obj)
 
     def descr_member_get(self, space, w_obj, w_cls=None):
         """member.__get__(obj[, type]) -> value
@@ -627,10 +624,8 @@
 def descr_get_dict(space, w_obj):
     w_dict = w_obj.getdict(space)
     if w_dict is None:
-        typename = space.type(w_obj).getname(space)
-        raise operationerrfmt(space.w_TypeError,
-                              "descriptor '__dict__' doesn't apply to"
-                              " '%s' objects", typename)
+        msg = "descriptor '__dict__' doesn't apply to '%T' objects"
+        raise operationerrfmt(space.w_TypeError, msg, w_obj)
     return w_dict
 
 def descr_set_dict(space, w_obj, w_dict):
diff --git a/pypy/module/__builtin__/interp_classobj.py b/pypy/module/__builtin__/interp_classobj.py
--- a/pypy/module/__builtin__/interp_classobj.py
+++ b/pypy/module/__builtin__/interp_classobj.py
@@ -10,10 +10,8 @@
 
 
 def raise_type_err(space, argument, expected, w_obj):
-    type_name = space.type(w_obj).getname(space)
-    raise operationerrfmt(space.w_TypeError,
-                          "argument %s must be %s, not %s",
-                          argument, expected, type_name)
+    raise operationerrfmt(space.w_TypeError, "argument %s must be %s, not %T",
+                          argument, expected, w_obj)
 
 def unwrap_attr(space, w_attr):
     try:
diff --git a/pypy/module/_cffi_backend/ccallback.py b/pypy/module/_cffi_backend/ccallback.py
--- a/pypy/module/_cffi_backend/ccallback.py
+++ b/pypy/module/_cffi_backend/ccallback.py
@@ -27,8 +27,8 @@
         #
         if not space.is_true(space.callable(w_callable)):
             raise operationerrfmt(space.w_TypeError,
-                                  "expected a callable object, not %s",
-                                  space.type(w_callable).getname(space))
+                                  "expected a callable object, not %T",
+                                  w_callable)
         self.w_callable = w_callable
         #
         fresult = self.getfunctype().ctitem
diff --git a/pypy/module/_cffi_backend/ctypefunc.py b/pypy/module/_cffi_backend/ctypefunc.py
--- a/pypy/module/_cffi_backend/ctypefunc.py
+++ b/pypy/module/_cffi_backend/ctypefunc.py
@@ -54,8 +54,8 @@
             else:
                 raise operationerrfmt(space.w_TypeError,
                              "argument %d passed in the variadic part "
-                             "needs to be a cdata object (got %s)",
-                             i + 1, space.type(w_obj).getname(space))
+                             "needs to be a cdata object (got %T)",
+                             i + 1, w_obj)
             fvarargs[i] = ct
         ctypefunc = instantiate(W_CTypeFunc)
         ctypefunc.space = space
diff --git a/pypy/module/_cffi_backend/ctypeobj.py b/pypy/module/_cffi_backend/ctypeobj.py
--- a/pypy/module/_cffi_backend/ctypeobj.py
+++ b/pypy/module/_cffi_backend/ctypeobj.py
@@ -88,8 +88,7 @@
         else:
             return operationerrfmt(space.w_TypeError,
                                    "initializer for ctype '%s' must be a %s, "
-                                   "not %s", self.name, expected,
-                                   space.type(w_got).getname(space))
+                                   "not %T", self.name, expected, w_got)
 
     def _cannot_index(self):
         space = self.space
diff --git a/pypy/module/_codecs/interp_codecs.py b/pypy/module/_codecs/interp_codecs.py
--- a/pypy/module/_codecs/interp_codecs.py
+++ b/pypy/module/_codecs/interp_codecs.py
@@ -218,9 +218,8 @@
         text = u'\ufffd' * size
         return space.newtuple([space.wrap(text), w_end])
     else:
-        typename = space.type(w_exc).getname(space)
         raise operationerrfmt(space.w_TypeError,
-            "don't know how to handle %s in error callback", typename)
+            "don't know how to handle %T in error callback", w_exc)
 
 def xmlcharrefreplace_errors(space, w_exc):
     check_exception(space, w_exc)
@@ -239,9 +238,8 @@
             pos += 1
         return space.newtuple([space.wrap(builder.build()), w_end])
     else:
-        typename = space.type(w_exc).getname(space)
         raise operationerrfmt(space.w_TypeError,
-            "don't know how to handle %s in error callback", typename)
+            "don't know how to handle %T in error callback", w_exc)
 
 def backslashreplace_errors(space, w_exc):
     check_exception(space, w_exc)
@@ -272,9 +270,8 @@
             pos += 1
         return space.newtuple([space.wrap(builder.build()), w_end])
     else:
-        typename = space.type(w_exc).getname(space)
         raise operationerrfmt(space.w_TypeError,
-            "don't know how to handle %s in error callback", typename)
+            "don't know how to handle %T in error callback", w_exc)
 
 def register_builtin_error_handlers(space):
     "NOT_RPYTHON"
diff --git a/pypy/module/_io/interp_bytesio.py b/pypy/module/_io/interp_bytesio.py
--- a/pypy/module/_io/interp_bytesio.py
+++ b/pypy/module/_io/interp_bytesio.py
@@ -138,10 +138,8 @@
 
         if space.len_w(w_state) != 3:
             raise operationerrfmt(space.w_TypeError,
-                "%s.__setstate__ argument should be 3-tuple, got %s",
-                space.type(self).getname(space),
-                space.type(w_state).getname(space)
-            )
+                "%T.__setstate__ argument should be 3-tuple, got %T",
+                self, w_state)
         w_content, w_pos, w_dict = space.unpackiterable(w_state, 3)
         self.truncate(0)
         self.write_w(space, w_content)
diff --git a/pypy/module/_io/interp_iobase.py b/pypy/module/_io/interp_iobase.py
--- a/pypy/module/_io/interp_iobase.py
+++ b/pypy/module/_io/interp_iobase.py
@@ -163,8 +163,8 @@
                 if not space.isinstance_w(w_readahead, space.w_str):
                     raise operationerrfmt(
                         space.w_IOError,
-                        "peek() should have returned a bytes object, "
-                        "not '%s'", space.type(w_readahead).getname(space))
+                        "peek() should have returned a bytes object, not '%T'",
+                        w_readahead)
                 length = space.len_w(w_readahead)
                 if length > 0:
                     n = 0
@@ -189,8 +189,8 @@
             if not space.isinstance_w(w_read, space.w_str):
                 raise operationerrfmt(
                     space.w_IOError,
-                    "peek() should have returned a bytes object, "
-                    "not '%s'", space.type(w_read).getname(space))
+                    "peek() should have returned a bytes object, not '%T'",
+                    w_read)
             read = space.str_w(w_read)
             if not read:
                 break
diff --git a/pypy/module/_io/interp_stringio.py b/pypy/module/_io/interp_stringio.py
--- a/pypy/module/_io/interp_stringio.py
+++ b/pypy/module/_io/interp_stringio.py
@@ -71,10 +71,8 @@
         # backwards-compatibility
         if not space.isinstance_w(w_state, space.w_tuple) or space.len_w(w_state) < 4:
             raise operationerrfmt(space.w_TypeError,
-                "%s.__setstate__ argument should be a 4-tuple, got %s",
-                space.type(self).getname(space),
-                space.type(w_state).getname(space)
-            )
+                "%T.__setstate__ argument should be a 4-tuple, got %T",
+                self, w_state)
         w_initval, w_readnl, w_pos, w_dict = space.unpackiterable(w_state, 4)
         # Initialize state
         self.descr_init(space, w_initval, w_readnl)
@@ -98,9 +96,8 @@
         if not space.is_w(w_dict, space.w_None):
             if not space.isinstance_w(w_dict, space.w_dict):
                 raise operationerrfmt(space.w_TypeError,
-                    "fourth item of state should be a dict, got a %s",
-                    space.type(w_dict).getname(space)
-                )
+                    "fourth item of state should be a dict, got a %T",
+                    w_dict)
             # Alternatively, we could replace the internal dictionary
             # completely. However, it seems more practical to just update it.
             space.call_method(self.w_dict, "update", w_dict)
@@ -129,8 +126,8 @@
     def write_w(self, space, w_obj):
         if not space.isinstance_w(w_obj, space.w_unicode):
             raise operationerrfmt(space.w_TypeError,
-                                  "unicode argument expected, got '%s'",
-                                  space.type(w_obj).getname(space))
+                                  "unicode argument expected, got '%T'",
+                                  w_obj)
         self._check_closed(space)
 
         orig_size = space.len_w(w_obj)
diff --git a/pypy/module/_rawffi/structure.py b/pypy/module/_rawffi/structure.py
--- a/pypy/module/_rawffi/structure.py
+++ b/pypy/module/_rawffi/structure.py
@@ -31,9 +31,8 @@
         try:
             name = space.str_w(l_w[0])
         except OperationError:
-            raise OperationError(space.w_TypeError, space.wrap(
-               "structure field name must be string not %s" %
-               space.type(l_w[0]).getname(space)))
+            raise operationerrfmt(space.w_TypeError,
+                "structure field name must be string not %T", l_w[0])
         tp = unpack_shape_with_length(space, l_w[1])
 
         if len_l == 3:
diff --git a/pypy/module/cppyy/converter.py b/pypy/module/cppyy/converter.py
--- a/pypy/module/cppyy/converter.py
+++ b/pypy/module/cppyy/converter.py
@@ -1,6 +1,6 @@
 import sys
 
-from pypy.interpreter.error import OperationError
+from pypy.interpreter.error import OperationError, operationerrfmt
 
 from rpython.rtyper.lltypesystem import rffi, lltype
 from rpython.rlib.rarithmetic import r_singlefloat
@@ -430,9 +430,8 @@
                 offset = capi.c_base_offset(space, w_obj.cppclass, self.cppclass, rawobject, 1)
                 obj_address = capi.direct_ptradd(rawobject, offset)
                 return rffi.cast(capi.C_OBJECT, obj_address)
-        raise OperationError(space.w_TypeError,
-                             space.wrap("cannot pass %s as %s" %
-                             (space.type(w_obj).getname(space, "?"), self.cppclass.name)))
+        raise operationerrfmt(space.w_TypeError, "cannot pass %T as %s",
+                              w_obj, self.cppclass.name)
 
     def convert_argument(self, space, w_obj, address, call_local):
         x = rffi.cast(rffi.VOIDPP, address)
diff --git a/pypy/module/cpyext/sequence.py b/pypy/module/cpyext/sequence.py
--- a/pypy/module/cpyext/sequence.py
+++ b/pypy/module/cpyext/sequence.py
@@ -153,8 +153,9 @@
     is the equivalent of the Python statement o[i] = v.  This function does
     not steal a reference to v."""
     if PyDict_Check(space, w_o) or not PySequence_Check(space, w_o):
-        raise operationerrfmt(space.w_TypeError, "'%s' object does not support item assignment",
-                             space.type(w_o).getname(space))
+        raise operationerrfmt(space.w_TypeError,
+                              "'%T' object does not support item assignment",
+                              w_o)
     space.setitem(w_o, space.wrap(i), w_v)
     return 0
 
diff --git a/pypy/module/cpyext/slotdefs.py b/pypy/module/cpyext/slotdefs.py
--- a/pypy/module/cpyext/slotdefs.py
+++ b/pypy/module/cpyext/slotdefs.py
@@ -274,11 +274,9 @@
 
     if not space.is_true(space.issubtype(space.type(w_self),
                                          space.type(w_other))):
-        raise OperationError(space.w_TypeError, space.wrap(
-            "%s.__cmp__(x,y) requires y to be a '%s', not a '%s'" %
-            (space.type(w_self).getname(space),
-             space.type(w_self).getname(space),
-             space.type(w_other).getname(space))))
+        raise operationerrfmt(space.w_TypeError,
+            "%T.__cmp__(x,y) requires y to be a '%T', not a '%T'",
+            w_self, w_self, w_other)
 
     return space.wrap(generic_cpy_call(space, func_target, w_self, w_other))
 
diff --git a/pypy/module/micronumpy/interp_dtype.py b/pypy/module/micronumpy/interp_dtype.py
--- a/pypy/module/micronumpy/interp_dtype.py
+++ b/pypy/module/micronumpy/interp_dtype.py
@@ -1,7 +1,7 @@
 
 import sys
 from pypy.interpreter.baseobjspace import W_Root
-from pypy.interpreter.error import OperationError
+from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.interpreter.gateway import interp2app, unwrap_spec
 from pypy.interpreter.typedef import (TypeDef, GetSetProperty,
     interp_attrproperty, interp_attrproperty_w)
@@ -401,10 +401,8 @@
             return dtype
         if w_dtype is dtype.w_box_type:
             return dtype
-    typename = space.type(w_dtype).getname(space)
-    raise OperationError(space.w_TypeError, space.wrap(
-                             "data type not understood (value of type " +
-                             "%s not expected here)" % typename))
+    msg = "data type not understood (value of type %T not expected here)"
+    raise operationerrfmt(space.w_TypeError, msg, w_dtype)
 
 W_Dtype.typedef = TypeDef("dtype",
     __module__ = "numpypy",
diff --git a/pypy/module/oracle/interp_variable.py b/pypy/module/oracle/interp_variable.py
--- a/pypy/module/oracle/interp_variable.py
+++ b/pypy/module/oracle/interp_variable.py
@@ -2,7 +2,7 @@
 from pypy.interpreter.typedef import TypeDef
 from pypy.interpreter.typedef import interp_attrproperty
 from pypy.interpreter.gateway import interp2app, unwrap_spec
-from pypy.interpreter.error import OperationError
+from pypy.interpreter.error import OperationError, operationerrfmt
 from rpython.rtyper.lltypesystem import rffi, lltype
 from rpython.rlib.rarithmetic import ovfcheck
 
@@ -1486,10 +1486,9 @@
         varType, size, _ = typeByValue(space, w_element, numElements)
         return varType, size, len(elements_w)
 
-    raise OperationError(
-        moduledict.w_NotSupportedError,
-        space.wrap("Variable_TypeByValue(): unhandled data type %s" %
-                   (space.type(w_value).getname(space),)))
+    raise operationerrfmt(moduledict.w_NotSupportedError,
+                          "Variable_TypeByValue(): unhandled data type %T",
+                          w_value)
 
 def newByInputTypeHandler(space, cursor, w_inputTypeHandler, w_value, numElements):
     w_var = space.call(w_inputTypeHandler,
diff --git a/pypy/module/pyexpat/interp_pyexpat.py b/pypy/module/pyexpat/interp_pyexpat.py
--- a/pypy/module/pyexpat/interp_pyexpat.py
+++ b/pypy/module/pyexpat/interp_pyexpat.py
@@ -1,7 +1,7 @@
 from pypy.interpreter.baseobjspace import W_Root
 from pypy.interpreter.typedef import TypeDef, GetSetProperty
 from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault
-from pypy.interpreter.error import OperationError
+from pypy.interpreter.error import OperationError, operationerrfmt
 from rpython.rlib import rgc, jit
 from rpython.rtyper.lltypesystem import rffi, lltype
 from rpython.rtyper.tool import rffi_platform
@@ -801,11 +801,10 @@
     elif space.isinstance_w(w_encoding, space.w_str):
         encoding = space.str_w(w_encoding)
     else:
-        type_name = space.type(w_encoding).getname(space)
-        raise OperationError(
+        raise operationerrfmt(
             space.w_TypeError,
-            space.wrap('ParserCreate() argument 1 must be string or None,'
-                       ' not %s' % (type_name,)))
+            'ParserCreate() argument 1 must be string or None, not %T',
+            w_encoding)
 
     if space.is_none(w_namespace_separator):
         namespace_separator = 0
@@ -821,11 +820,10 @@
                 space.wrap('namespace_separator must be at most one character,'
                            ' omitted, or None'))
     else:
-        type_name = space.type(w_namespace_separator).getname(space)
-        raise OperationError(
+        raise operationerrfmt(
             space.w_TypeError,
-            space.wrap('ParserCreate() argument 2 must be string or None,'
-                       ' not %s' % (type_name,)))
+            'ParserCreate() argument 2 must be string or None, not %T',
+            w_namespace_separator)
 
     # Explicitly passing None means no interning is desired.
     # Not passing anything means that a new dictionary is used.
diff --git a/pypy/objspace/descroperation.py b/pypy/objspace/descroperation.py
--- a/pypy/objspace/descroperation.py
+++ b/pypy/objspace/descroperation.py
@@ -52,16 +52,14 @@
 list_iter._annspecialcase_ = 'specialize:memo'
 
 def raiseattrerror(space, w_obj, name, w_descr=None):
-    w_type = space.type(w_obj)
-    typename = w_type.getname(space)
     if w_descr is None:
         raise operationerrfmt(space.w_AttributeError,
-                              "'%s' object has no attribute '%s'",
-                              typename, name)
+                              "'%T' object has no attribute '%s'",
+                              w_obj, name)
     else:
         raise operationerrfmt(space.w_AttributeError,
-                              "'%s' object attribute '%s' is read-only",
-                              typename, name)
+                              "'%T' object attribute '%s' is read-only",
+                              w_obj, name)
 
 # Helpers for old-style and mix-style mixup
 
@@ -162,10 +160,9 @@
             return w_obj.call_args(args)
         w_descr = space.lookup(w_obj, '__call__')
         if w_descr is None:
-            typename = space.type(w_obj).getname(space)
             raise operationerrfmt(space.w_TypeError,
-                                  "'%s' object is not callable",
-                                  typename)
+                                  "'%T' object is not callable",
+                                  w_obj)
         return space.get_and_call_args(w_descr, w_obj, args)
 
     def get(space, w_descr, w_obj, w_type=None):
@@ -179,19 +176,17 @@
     def set(space, w_descr, w_obj, w_val):
         w_set = space.lookup(w_descr, '__set__')
         if w_set is None:
-            typename = space.type(w_descr).getname(space)
             raise operationerrfmt(space.w_TypeError,
-                                  "'%s' object is not a descriptor with set",
-                                  typename)
+                                  "'%T' object is not a descriptor with set",
+                                  w_descr)
         return space.get_and_call_function(w_set, w_descr, w_obj, w_val)
 
     def delete(space, w_descr, w_obj):
         w_delete = space.lookup(w_descr, '__delete__')
         if w_delete is None:
-            typename = space.type(w_descr).getname(space)
             raise operationerrfmt(space.w_TypeError,
-                                  "'%s' object is not a descriptor with delete",
-                                  typename)
+                                  "'%T' object is not a descriptor with delete",
+                                  w_descr)
         return space.get_and_call_function(w_delete, w_descr, w_obj)
 
     def getattr(space, w_obj, w_name):
@@ -215,19 +210,17 @@
     def setattr(space, w_obj, w_name, w_val):
         w_descr = space.lookup(w_obj, '__setattr__')
         if w_descr is None:
-            typename = space.type(w_obj).getname(space)
             raise operationerrfmt(space.w_AttributeError,
-                                  "'%s' object is readonly",
-                                  typename)
+                                  "'%T' object is readonly",
+                                  w_obj)
         return space.get_and_call_function(w_descr, w_obj, w_name, w_val)
 
     def delattr(space, w_obj, w_name):
         w_descr = space.lookup(w_obj, '__delattr__')
         if w_descr is None:
-            typename = space.type(w_obj).getname(space)
             raise operationerrfmt(space.w_AttributeError,
-                                  "'%s' object does not support attribute removal",
-                                  typename)
+                                  "'%T' object does not support attribute removal",
+                                  w_obj)
         return space.get_and_call_function(w_descr, w_obj, w_name)
 
     def is_true(space, w_obj):
@@ -264,9 +257,8 @@
     def len(space, w_obj):
         w_descr = space.lookup(w_obj, '__len__')
         if w_descr is None:
-            name = space.type(w_obj).getname(space)
-            msg = "'%s' has no length" % (name,)
-            raise OperationError(space.w_TypeError, space.wrap(msg))
+            raise operationerrfmt(space.w_TypeError, "'%T' has no length",
+                                  w_obj)
         w_res = space.get_and_call_function(w_descr, w_obj)
         return space.wrap(space._check_len_result(w_res))
 
@@ -283,10 +275,9 @@
         if w_descr is None:
             w_descr = space.lookup(w_obj, '__getitem__')
             if w_descr is None:
-                typename = space.type(w_obj).getname(space)
                 raise operationerrfmt(space.w_TypeError,
-                                      "'%s' object is not iterable",
-                                      typename)
+                                      "'%T' object is not iterable",
+                                      w_obj)
             return space.newseqiter(w_obj)
         w_iter = space.get_and_call_function(w_descr, w_obj)
         w_next = space.lookup(w_iter, 'next')
@@ -298,37 +289,34 @@
     def next(space, w_obj):
         w_descr = space.lookup(w_obj, 'next')
         if w_descr is None:
-            typename = space.type(w_obj).getname(space)
             raise operationerrfmt(space.w_TypeError,
-                                  "'%s' object is not an iterator",
-                                  typename)
+                                  "'%T' object is not an iterator",
+                                  w_obj)
         return space.get_and_call_function(w_descr, w_obj)
 
     def getitem(space, w_obj, w_key):
         w_descr = space.lookup(w_obj, '__getitem__')
         if w_descr is None:
-            typename = space.type(w_obj).getname(space)
             raise operationerrfmt(space.w_TypeError,
-                                  "'%s' object is not subscriptable",
-                                  typename)
+                                  "'%T' object is not subscriptable",
+                                  w_obj)
         return space.get_and_call_function(w_descr, w_obj, w_key)
 
     def setitem(space, w_obj, w_key, w_val):
         w_descr = space.lookup(w_obj, '__setitem__')
         if w_descr is None:
-            typename = space.type(w_obj).getname(space)
-            raise operationerrfmt(space.w_TypeError,
-                              "'%s' object does not support item assignment",
-                                  typename)
+            raise operationerrfmt(
+                space.w_TypeError,
+                "'%T' object does not support item assignment",
+                w_obj)
         return space.get_and_call_function(w_descr, w_obj, w_key, w_val)
 
     def delitem(space, w_obj, w_key):
         w_descr = space.lookup(w_obj, '__delitem__')
         if w_descr is None:
-            typename = space.type(w_obj).getname(space)
             raise operationerrfmt(space.w_TypeError,
-                                "'%s' object does not support item deletion",
-                                  typename)
+                                "'%T' object does not support item deletion",
+                                  w_obj)
         return space.get_and_call_function(w_descr, w_obj, w_key)
 
     def getslice(space, w_obj, w_start, w_stop):
@@ -358,17 +346,13 @@
     def format(space, w_obj, w_format_spec):
         w_descr = space.lookup(w_obj, '__format__')
         if w_descr is None:
-            typename = space.type(w_obj).getname(space)
             raise operationerrfmt(space.w_TypeError,
-                                  "'%s' object does not define __format__",
-                                  typename)
+                                  "'%T' object does not define __format__",
+                                  w_obj)
         w_res = space.get_and_call_function(w_descr, w_obj, w_format_spec)
         if not space.isinstance_w(w_res, space.w_basestring):
-            typename = space.type(w_obj).getname(space)
-            restypename = space.type(w_res).getname(space)
-            raise operationerrfmt(space.w_TypeError,
-                "%s.__format__ must return string or unicode, not %s",
-                                  typename, restypename)
+            msg = "%T.__format__ must return string or unicode, not %T"
+            raise operationerrfmt(space.w_TypeError, msg, w_obj, w_res)
         return w_res
 
     def pow(space, w_obj1, w_obj2, w_obj3):
@@ -444,9 +428,8 @@
             # obscure circumstances.
             return default_identity_hash(space, w_obj)
         if space.is_w(w_hash, space.w_None):
-            typename = space.type(w_obj).getname(space)
             raise operationerrfmt(space.w_TypeError,
-                                  "'%s' objects are unhashable", typename)


More information about the pypy-commit mailing list