Amaury Forgeot d'Arc avatar Amaury Forgeot d'Arc committed 09ee6be

Display the name of the derived class in AttributeError messages

Comments (0)

Files changed (3)

pypy/interpreter/astcompiler/ast.py

 
 def Module_get_body(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'Module' object has no attribute 'body'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'body'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_body is None:
         if w_self.body is None:
 
 def Interactive_get_body(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'Interactive' object has no attribute 'body'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'body'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_body is None:
         if w_self.body is None:
 
 def Expression_get_body(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'Expression' object has no attribute 'body'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'body'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.body)
 
 
 def Suite_get_body(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'Suite' object has no attribute 'body'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'body'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_body is None:
         if w_self.body is None:
 
 def stmt_get_lineno(space, w_self):
     if not w_self.initialization_state & w_self._lineno_mask:
-        w_err = space.wrap("'stmt' object has no attribute 'lineno'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'lineno'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.lineno)
 
 
 def stmt_get_col_offset(space, w_self):
     if not w_self.initialization_state & w_self._col_offset_mask:
-        w_err = space.wrap("'stmt' object has no attribute 'col_offset'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'col_offset'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.col_offset)
 
 
 def FunctionDef_get_name(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'FunctionDef' object has no attribute 'name'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'name'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.name)
 
 
 def FunctionDef_get_args(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'FunctionDef' object has no attribute 'args'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'args'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.args)
 
 
 def FunctionDef_get_body(space, w_self):
     if not w_self.initialization_state & 4:
-        w_err = space.wrap("'FunctionDef' object has no attribute 'body'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'body'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_body is None:
         if w_self.body is None:
 
 def FunctionDef_get_decorator_list(space, w_self):
     if not w_self.initialization_state & 8:
-        w_err = space.wrap("'FunctionDef' object has no attribute 'decorator_list'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'decorator_list'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_decorator_list is None:
         if w_self.decorator_list is None:
 
 def ClassDef_get_name(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'ClassDef' object has no attribute 'name'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'name'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.name)
 
 
 def ClassDef_get_bases(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'ClassDef' object has no attribute 'bases'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'bases'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_bases is None:
         if w_self.bases is None:
 
 def ClassDef_get_body(space, w_self):
     if not w_self.initialization_state & 4:
-        w_err = space.wrap("'ClassDef' object has no attribute 'body'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'body'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_body is None:
         if w_self.body is None:
 
 def ClassDef_get_decorator_list(space, w_self):
     if not w_self.initialization_state & 8:
-        w_err = space.wrap("'ClassDef' object has no attribute 'decorator_list'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'decorator_list'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_decorator_list is None:
         if w_self.decorator_list is None:
 
 def Return_get_value(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'Return' object has no attribute 'value'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'value'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.value)
 
 
 def Delete_get_targets(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'Delete' object has no attribute 'targets'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'targets'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_targets is None:
         if w_self.targets is None:
 
 def Assign_get_targets(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'Assign' object has no attribute 'targets'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'targets'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_targets is None:
         if w_self.targets is None:
 
 def Assign_get_value(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'Assign' object has no attribute 'value'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'value'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.value)
 
 
 def AugAssign_get_target(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'AugAssign' object has no attribute 'target'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'target'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.target)
 
 
 def AugAssign_get_op(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'AugAssign' object has no attribute 'op'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'op'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return operator_to_class[w_self.op - 1]()
 
 
 def AugAssign_get_value(space, w_self):
     if not w_self.initialization_state & 4:
-        w_err = space.wrap("'AugAssign' object has no attribute 'value'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'value'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.value)
 
 
 def Print_get_dest(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'Print' object has no attribute 'dest'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'dest'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.dest)
 
 
 def Print_get_values(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'Print' object has no attribute 'values'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'values'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_values is None:
         if w_self.values is None:
 
 def Print_get_nl(space, w_self):
     if not w_self.initialization_state & 4:
-        w_err = space.wrap("'Print' object has no attribute 'nl'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'nl'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.nl)
 
 
 def For_get_target(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'For' object has no attribute 'target'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'target'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.target)
 
 
 def For_get_iter(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'For' object has no attribute 'iter'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'iter'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.iter)
 
 
 def For_get_body(space, w_self):
     if not w_self.initialization_state & 4:
-        w_err = space.wrap("'For' object has no attribute 'body'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'body'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_body is None:
         if w_self.body is None:
 
 def For_get_orelse(space, w_self):
     if not w_self.initialization_state & 8:
-        w_err = space.wrap("'For' object has no attribute 'orelse'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'orelse'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_orelse is None:
         if w_self.orelse is None:
 
 def While_get_test(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'While' object has no attribute 'test'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'test'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.test)
 
 
 def While_get_body(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'While' object has no attribute 'body'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'body'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_body is None:
         if w_self.body is None:
 
 def While_get_orelse(space, w_self):
     if not w_self.initialization_state & 4:
-        w_err = space.wrap("'While' object has no attribute 'orelse'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'orelse'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_orelse is None:
         if w_self.orelse is None:
 
 def If_get_test(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'If' object has no attribute 'test'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'test'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.test)
 
 
 def If_get_body(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'If' object has no attribute 'body'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'body'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_body is None:
         if w_self.body is None:
 
 def If_get_orelse(space, w_self):
     if not w_self.initialization_state & 4:
-        w_err = space.wrap("'If' object has no attribute 'orelse'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'orelse'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_orelse is None:
         if w_self.orelse is None:
 
 def With_get_context_expr(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'With' object has no attribute 'context_expr'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'context_expr'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.context_expr)
 
 
 def With_get_optional_vars(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'With' object has no attribute 'optional_vars'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'optional_vars'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.optional_vars)
 
 
 def With_get_body(space, w_self):
     if not w_self.initialization_state & 4:
-        w_err = space.wrap("'With' object has no attribute 'body'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'body'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_body is None:
         if w_self.body is None:
 
 def Raise_get_type(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'Raise' object has no attribute 'type'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'type'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.type)
 
 
 def Raise_get_inst(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'Raise' object has no attribute 'inst'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'inst'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.inst)
 
 
 def Raise_get_tback(space, w_self):
     if not w_self.initialization_state & 4:
-        w_err = space.wrap("'Raise' object has no attribute 'tback'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'tback'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.tback)
 
 
 def TryExcept_get_body(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'TryExcept' object has no attribute 'body'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'body'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_body is None:
         if w_self.body is None:
 
 def TryExcept_get_handlers(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'TryExcept' object has no attribute 'handlers'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'handlers'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_handlers is None:
         if w_self.handlers is None:
 
 def TryExcept_get_orelse(space, w_self):
     if not w_self.initialization_state & 4:
-        w_err = space.wrap("'TryExcept' object has no attribute 'orelse'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'orelse'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_orelse is None:
         if w_self.orelse is None:
 
 def TryFinally_get_body(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'TryFinally' object has no attribute 'body'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'body'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_body is None:
         if w_self.body is None:
 
 def TryFinally_get_finalbody(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'TryFinally' object has no attribute 'finalbody'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'finalbody'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_finalbody is None:
         if w_self.finalbody is None:
 
 def Assert_get_test(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'Assert' object has no attribute 'test'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'test'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.test)
 
 
 def Assert_get_msg(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'Assert' object has no attribute 'msg'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'msg'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.msg)
 
 
 def Import_get_names(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'Import' object has no attribute 'names'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'names'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_names is None:
         if w_self.names is None:
 
 def ImportFrom_get_module(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'ImportFrom' object has no attribute 'module'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'module'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.module)
 
 
 def ImportFrom_get_names(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'ImportFrom' object has no attribute 'names'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'names'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_names is None:
         if w_self.names is None:
 
 def ImportFrom_get_level(space, w_self):
     if not w_self.initialization_state & 4:
-        w_err = space.wrap("'ImportFrom' object has no attribute 'level'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'level'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.level)
 
 
 def Exec_get_body(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'Exec' object has no attribute 'body'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'body'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.body)
 
 
 def Exec_get_globals(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'Exec' object has no attribute 'globals'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'globals'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.globals)
 
 
 def Exec_get_locals(space, w_self):
     if not w_self.initialization_state & 4:
-        w_err = space.wrap("'Exec' object has no attribute 'locals'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'locals'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.locals)
 
 
 def Global_get_names(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'Global' object has no attribute 'names'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'names'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_names is None:
         if w_self.names is None:
 
 def Expr_get_value(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'Expr' object has no attribute 'value'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'value'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.value)
 
 
 def expr_get_lineno(space, w_self):
     if not w_self.initialization_state & w_self._lineno_mask:
-        w_err = space.wrap("'expr' object has no attribute 'lineno'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'lineno'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.lineno)
 
 
 def expr_get_col_offset(space, w_self):
     if not w_self.initialization_state & w_self._col_offset_mask:
-        w_err = space.wrap("'expr' object has no attribute 'col_offset'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'col_offset'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.col_offset)
 
 
 def BoolOp_get_op(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'BoolOp' object has no attribute 'op'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'op'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return boolop_to_class[w_self.op - 1]()
 
 
 def BoolOp_get_values(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'BoolOp' object has no attribute 'values'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'values'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_values is None:
         if w_self.values is None:
 
 def BinOp_get_left(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'BinOp' object has no attribute 'left'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'left'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.left)
 
 
 def BinOp_get_op(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'BinOp' object has no attribute 'op'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'op'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return operator_to_class[w_self.op - 1]()
 
 
 def BinOp_get_right(space, w_self):
     if not w_self.initialization_state & 4:
-        w_err = space.wrap("'BinOp' object has no attribute 'right'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'right'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.right)
 
 
 def UnaryOp_get_op(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'UnaryOp' object has no attribute 'op'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'op'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return unaryop_to_class[w_self.op - 1]()
 
 
 def UnaryOp_get_operand(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'UnaryOp' object has no attribute 'operand'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'operand'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.operand)
 
 
 def Lambda_get_args(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'Lambda' object has no attribute 'args'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'args'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.args)
 
 
 def Lambda_get_body(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'Lambda' object has no attribute 'body'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'body'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.body)
 
 
 def IfExp_get_test(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'IfExp' object has no attribute 'test'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'test'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.test)
 
 
 def IfExp_get_body(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'IfExp' object has no attribute 'body'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'body'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.body)
 
 
 def IfExp_get_orelse(space, w_self):
     if not w_self.initialization_state & 4:
-        w_err = space.wrap("'IfExp' object has no attribute 'orelse'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'orelse'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.orelse)
 
 
 def Dict_get_keys(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'Dict' object has no attribute 'keys'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'keys'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_keys is None:
         if w_self.keys is None:
 
 def Dict_get_values(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'Dict' object has no attribute 'values'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'values'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_values is None:
         if w_self.values is None:
 
 def Set_get_elts(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'Set' object has no attribute 'elts'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'elts'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_elts is None:
         if w_self.elts is None:
 
 def ListComp_get_elt(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'ListComp' object has no attribute 'elt'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'elt'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.elt)
 
 
 def ListComp_get_generators(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'ListComp' object has no attribute 'generators'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'generators'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_generators is None:
         if w_self.generators is None:
 
 def SetComp_get_elt(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'SetComp' object has no attribute 'elt'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'elt'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.elt)
 
 
 def SetComp_get_generators(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'SetComp' object has no attribute 'generators'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'generators'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_generators is None:
         if w_self.generators is None:
 
 def DictComp_get_key(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'DictComp' object has no attribute 'key'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'key'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.key)
 
 
 def DictComp_get_value(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'DictComp' object has no attribute 'value'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'value'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.value)
 
 
 def DictComp_get_generators(space, w_self):
     if not w_self.initialization_state & 4:
-        w_err = space.wrap("'DictComp' object has no attribute 'generators'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'generators'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_generators is None:
         if w_self.generators is None:
 
 def GeneratorExp_get_elt(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'GeneratorExp' object has no attribute 'elt'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'elt'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.elt)
 
 
 def GeneratorExp_get_generators(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'GeneratorExp' object has no attribute 'generators'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'generators'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_generators is None:
         if w_self.generators is None:
 
 def Yield_get_value(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'Yield' object has no attribute 'value'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'value'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.value)
 
 
 def Compare_get_left(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'Compare' object has no attribute 'left'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'left'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.left)
 
 
 def Compare_get_ops(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'Compare' object has no attribute 'ops'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'ops'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_ops is None:
         if w_self.ops is None:
 
 def Compare_get_comparators(space, w_self):
     if not w_self.initialization_state & 4:
-        w_err = space.wrap("'Compare' object has no attribute 'comparators'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'comparators'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_comparators is None:
         if w_self.comparators is None:
 
 def Call_get_func(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'Call' object has no attribute 'func'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'func'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.func)
 
 
 def Call_get_args(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'Call' object has no attribute 'args'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'args'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_args is None:
         if w_self.args is None:
 
 def Call_get_keywords(space, w_self):
     if not w_self.initialization_state & 4:
-        w_err = space.wrap("'Call' object has no attribute 'keywords'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'keywords'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_keywords is None:
         if w_self.keywords is None:
 
 def Call_get_starargs(space, w_self):
     if not w_self.initialization_state & 8:
-        w_err = space.wrap("'Call' object has no attribute 'starargs'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'starargs'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.starargs)
 
 
 def Call_get_kwargs(space, w_self):
     if not w_self.initialization_state & 16:
-        w_err = space.wrap("'Call' object has no attribute 'kwargs'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'kwargs'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.kwargs)
 
 
 def Repr_get_value(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'Repr' object has no attribute 'value'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'value'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.value)
 
 
 def Num_get_n(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'Num' object has no attribute 'n'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'n'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return w_self.n
 
 
 def Str_get_s(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'Str' object has no attribute 's'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 's'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return w_self.s
 
 
 def Attribute_get_value(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'Attribute' object has no attribute 'value'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'value'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.value)
 
 
 def Attribute_get_attr(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'Attribute' object has no attribute 'attr'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'attr'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.attr)
 
 
 def Attribute_get_ctx(space, w_self):
     if not w_self.initialization_state & 4:
-        w_err = space.wrap("'Attribute' object has no attribute 'ctx'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'ctx'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return expr_context_to_class[w_self.ctx - 1]()
 
 
 def Subscript_get_value(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'Subscript' object has no attribute 'value'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'value'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.value)
 
 
 def Subscript_get_slice(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'Subscript' object has no attribute 'slice'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'slice'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.slice)
 
 
 def Subscript_get_ctx(space, w_self):
     if not w_self.initialization_state & 4:
-        w_err = space.wrap("'Subscript' object has no attribute 'ctx'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'ctx'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return expr_context_to_class[w_self.ctx - 1]()
 
 
 def Name_get_id(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'Name' object has no attribute 'id'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'id'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.id)
 
 
 def Name_get_ctx(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'Name' object has no attribute 'ctx'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'ctx'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return expr_context_to_class[w_self.ctx - 1]()
 
 
 def List_get_elts(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'List' object has no attribute 'elts'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'elts'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_elts is None:
         if w_self.elts is None:
 
 def List_get_ctx(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'List' object has no attribute 'ctx'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'ctx'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return expr_context_to_class[w_self.ctx - 1]()
 
 
 def Tuple_get_elts(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'Tuple' object has no attribute 'elts'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'elts'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_elts is None:
         if w_self.elts is None:
 
 def Tuple_get_ctx(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'Tuple' object has no attribute 'ctx'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'ctx'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return expr_context_to_class[w_self.ctx - 1]()
 
 
 def Const_get_value(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'Const' object has no attribute 'value'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'value'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return w_self.value
 
 
 def Slice_get_lower(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'Slice' object has no attribute 'lower'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'lower'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.lower)
 
 
 def Slice_get_upper(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'Slice' object has no attribute 'upper'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'upper'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.upper)
 
 
 def Slice_get_step(space, w_self):
     if not w_self.initialization_state & 4:
-        w_err = space.wrap("'Slice' object has no attribute 'step'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'step'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.step)
 
 
 def ExtSlice_get_dims(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'ExtSlice' object has no attribute 'dims'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'dims'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_dims is None:
         if w_self.dims is None:
 
 def Index_get_value(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'Index' object has no attribute 'value'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'value'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.value)
 
 
 def comprehension_get_target(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'comprehension' object has no attribute 'target'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'target'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.target)
 
 
 def comprehension_get_iter(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'comprehension' object has no attribute 'iter'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'iter'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.iter)
 
 
 def comprehension_get_ifs(space, w_self):
     if not w_self.initialization_state & 4:
-        w_err = space.wrap("'comprehension' object has no attribute 'ifs'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'ifs'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_ifs is None:
         if w_self.ifs is None:
 
 def excepthandler_get_lineno(space, w_self):
     if not w_self.initialization_state & w_self._lineno_mask:
-        w_err = space.wrap("'excepthandler' object has no attribute 'lineno'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'lineno'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.lineno)
 
 
 def excepthandler_get_col_offset(space, w_self):
     if not w_self.initialization_state & w_self._col_offset_mask:
-        w_err = space.wrap("'excepthandler' object has no attribute 'col_offset'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'col_offset'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.col_offset)
 
 
 def ExceptHandler_get_type(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'ExceptHandler' object has no attribute 'type'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'type'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.type)
 
 
 def ExceptHandler_get_name(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'ExceptHandler' object has no attribute 'name'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'name'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.name)
 
 
 def ExceptHandler_get_body(space, w_self):
     if not w_self.initialization_state & 4:
-        w_err = space.wrap("'ExceptHandler' object has no attribute 'body'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'body'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_body is None:
         if w_self.body is None:
 
 def arguments_get_args(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'arguments' object has no attribute 'args'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'args'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_args is None:
         if w_self.args is None:
 
 def arguments_get_vararg(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'arguments' object has no attribute 'vararg'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'vararg'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.vararg)
 
 
 def arguments_get_kwarg(space, w_self):
     if not w_self.initialization_state & 4:
-        w_err = space.wrap("'arguments' object has no attribute 'kwarg'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'kwarg'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.kwarg)
 
 
 def arguments_get_defaults(space, w_self):
     if not w_self.initialization_state & 8:
-        w_err = space.wrap("'arguments' object has no attribute 'defaults'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'defaults'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     if w_self.w_defaults is None:
         if w_self.defaults is None:
 
 def keyword_get_arg(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'keyword' object has no attribute 'arg'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'arg'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.arg)
 
 
 def keyword_get_value(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'keyword' object has no attribute 'value'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'value'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.value)
 
 
 def alias_get_name(space, w_self):
     if not w_self.initialization_state & 1:
-        w_err = space.wrap("'alias' object has no attribute 'name'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'name'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.name)
 
 
 def alias_get_asname(space, w_self):
     if not w_self.initialization_state & 2:
-        w_err = space.wrap("'alias' object has no attribute 'asname'")
+        typename = space.type(w_self).getname(space)
+        w_err = space.wrap("'%s' object has no attribute 'asname'" % typename)
         raise OperationError(space.w_AttributeError, w_err)
     return space.wrap(w_self.asname)
 

pypy/interpreter/astcompiler/tools/asdl_py.py

         else:
             flag = self.data.field_masks[field]
         self.emit("if not w_self.initialization_state & %s:" % (flag,), 1)
-        self.emit("w_err = space.wrap(\"'%s' object has no attribute '%s'\")" %
-                  (name, field.name,), 2)
+        self.emit("typename = space.type(w_self).getname(space)", 2)
+        self.emit("w_err = space.wrap(\"'%%s' object has no attribute '%s'\" %% typename)" %
+                  (field.name,), 2)
         self.emit("raise OperationError(space.w_AttributeError, w_err)", 2)
         if field.seq:
             self.emit("if w_self.w_%s is None:" % (field.name,), 1)

pypy/module/_ast/test/test_ast.py

         exc = raises(AttributeError, getattr, x, 'n')
         assert exc.value.args[0] == "'Num' object has no attribute 'n'"
 
+        x = ast.Num(42)
+        assert x.n == 42
+        exc = raises(AttributeError, getattr, x, 'lineno')
+        assert exc.value.args[0] == "'Num' object has no attribute 'lineno'"
+
         skip("WIP")
 
-        x = ast.Num(42)
-        self.assertEquals(x.n, 42)
-        try:
-            x.lineno
-        except AttributeError, e:
-            self.assertEquals(e.args[0],
-                              "'Num' object has no attribute 'lineno'")
-        else:
-            self.assert_(False)
-
         y = ast.Num()
         x.lineno = y
-        self.assertEquals(x.lineno, y)
+        assert x.lineno == y
 
-        try:
-            x.foobar
-        except AttributeError, e:
-            self.assertEquals(e.args[0],
-                              "'Num' object has no attribute 'foobar'")
-        else:
-            self.assert_(False)
+        exc = raises(AttributeError, getattr, x, 'foobar')
+        assert exc.value.args[0] == "'Num' object has no attribute 'foobar'"
 
         x = ast.Num(lineno=2)
         self.assertEquals(x.lineno, 2)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.