Commits

Ronan Lamy committed 917b04a Merge

hg merge default

Comments (0)

Files changed (100)

dotviewer/graphdisplay.py

         Click on objects to move around
         Drag with the left mouse button to zoom in/out
         Drag with the right mouse button to scroll
+        Use scroll wheel do scroll up or down
     """.replace('\n    ', '\n').strip()  # poor man's dedent
 
 
     def process_MouseButtonUp(self, event):
         self.dragging = None
         pygame.event.set_grab(False)
+        # handle directional scrolling
+        if event.button == 4:
+            self.pan((0, -1))
+            return
+        if event.button == 5:
+            self.pan((0, 1))
+            return
+        if event.button == 6:
+            self.pan((-1, 0))
+            return
+        if event.button == 7:
+            self.pan((1, 0))
+            return
         if self.click_time is not None and abs(time.time() - self.click_time) < 1:
             # click (no significant dragging)
             self.notifyclick(self.click_origin)

pypy/interpreter/argument.py

 """
 Arguments objects.
 """
-
-from pypy.interpreter.error import OperationError, operationerrfmt
 from rpython.rlib.debug import make_sure_not_resized
 from rpython.rlib import jit
 
+from pypy.interpreter.error import OperationError, oefmt
+
 
 class Arguments(object):
     """
             args_w = space.fixedview(w_stararg)
         except OperationError, e:
             if e.match(space, space.w_TypeError):
-                raise operationerrfmt(
-                    space.w_TypeError,
-                    "argument after * must be a sequence, not %T", w_stararg)
+                raise oefmt(space.w_TypeError,
+                            "argument after * must be a sequence, not %T",
+                            w_stararg)
             raise
         self.arguments_w = self.arguments_w + args_w
 
                 w_keys = space.call_method(w_starstararg, "keys")
             except OperationError, e:
                 if e.match(space, space.w_AttributeError):
-                    raise operationerrfmt(
-                        space.w_TypeError,
-                        "argument after ** must be a mapping, not %T",
-                        w_starstararg)
+                    raise oefmt(space.w_TypeError,
+                                "argument after ** must be a mapping, not %T",
+                                w_starstararg)
                 raise
             keys_w = space.unpackiterable(w_keys)
         keywords_w = [None] * len(keys_w)
             self._match_signature(w_firstarg,
                                   scope_w, signature, defaults_w, 0)
         except ArgErr, e:
-            raise operationerrfmt(self.space.w_TypeError,
-                                  "%s() %s", fnname, e.getmsg())
+            raise oefmt(self.space.w_TypeError, "%s() %s", fnname, e.getmsg())
         return signature.scope_length()
 
     def _parse(self, w_firstarg, signature, defaults_w, blindargs=0):
         try:
             return self._parse(w_firstarg, signature, defaults_w, blindargs)
         except ArgErr, e:
-            raise operationerrfmt(self.space.w_TypeError,
-                                  "%s() %s", fnname, e.getmsg())
+            raise oefmt(self.space.w_TypeError, "%s() %s", fnname, e.getmsg())
 
     @staticmethod
     def frompacked(space, w_args=None, w_kwds=None):
     for key in keywords:
         for otherkey in existingkeywords:
             if otherkey == key:
-                raise operationerrfmt(space.w_TypeError,
-                                      "got multiple values "
-                                      "for keyword argument "
-                                      "'%s'", key)
+                raise oefmt(space.w_TypeError,
+                            "got multiple values for keyword argument '%s'",
+                            key)
 
 def _do_combine_starstarargs_wrapped(space, keys_w, w_starstararg, keywords,
         keywords_w, existingkeywords):
                 raise
         else:
             if existingkeywords and key in existingkeywords:
-                raise operationerrfmt(space.w_TypeError,
-                                      "got multiple values "
-                                      "for keyword argument "
-                                      "'%s'", key)
+                raise oefmt(space.w_TypeError,
+                            "got multiple values for keyword argument '%s'",
+                            key)
         keywords[i] = key
         keywords_w[i] = space.getitem(w_starstararg, w_key)
         i += 1

pypy/interpreter/astcompiler/ast.py

 # Generated by tools/asdl_py.py
-from pypy.interpreter.baseobjspace import W_Root
-from pypy.interpreter import typedef
-from pypy.interpreter.gateway import interp2app
-from pypy.interpreter.error import OperationError, operationerrfmt
 from rpython.rlib.unroll import unrolling_iterable
 from rpython.tool.pairtype import extendabletype
 from rpython.tool.sourcetools import func_with_new_name
 
+from pypy.interpreter import typedef
+from pypy.interpreter.baseobjspace import W_Root
+from pypy.interpreter.error import OperationError, oefmt
+from pypy.interpreter.gateway import interp2app
+
+
+def raise_attriberr(space, w_obj, name):
+    raise oefmt(space.w_AttributeError,
+                "'%T' object has no attribute '%s'", w_obj, name)
+
 
 def check_string(space, w_obj):
     if not (space.isinstance_w(w_obj, space.w_str) or
                 continue  # field is optional
             w_obj = self.getdictvalue(space, missing)
             if w_obj is None:
-                err = "required field \"%s\" missing from %s"
-                raise operationerrfmt(space.w_TypeError, err, missing, host)
+                raise oefmt(space.w_TypeError,
+                            "required field \"%s\" missing from %s",
+                            missing, host)
             else:
-                err = "incorrect type for field \"%s\" in %s"
-                raise operationerrfmt(space.w_TypeError, err, missing, host)
+                raise oefmt(space.w_TypeError,
+                            "incorrect type for field \"%s\" in %s",
+                            missing, host)
         raise AssertionError("should not reach here")
 
 
 
 def Module_get_body(space, w_self):
     if not w_self.initialization_state & 1:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
+        raise_attriberr(space, w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
 
 def Interactive_get_body(space, w_self):
     if not w_self.initialization_state & 1:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
+        raise_attriberr(space, w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 1:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
+        raise_attriberr(space, w_self, 'body')
     return space.wrap(w_self.body)
 
 def Expression_set_body(space, w_self, w_new_value):
 
 def Suite_get_body(space, w_self):
     if not w_self.initialization_state & 1:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
+        raise_attriberr(space, w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 1:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'lineno')
+        raise_attriberr(space, w_self, 'lineno')
     return space.wrap(w_self.lineno)
 
 def stmt_set_lineno(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 2:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'col_offset')
+        raise_attriberr(space, w_self, 'col_offset')
     return space.wrap(w_self.col_offset)
 
 def stmt_set_col_offset(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'name')
+        raise_attriberr(space, w_self, 'name')
     return space.wrap(w_self.name)
 
 def FunctionDef_set_name(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'args')
+        raise_attriberr(space, w_self, 'args')
     return space.wrap(w_self.args)
 
 def FunctionDef_set_args(space, w_self, w_new_value):
 
 def FunctionDef_get_body(space, w_self):
     if not w_self.initialization_state & 16:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
+        raise_attriberr(space, w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
 
 def FunctionDef_get_decorator_list(space, w_self):
     if not w_self.initialization_state & 32:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'decorator_list')
+        raise_attriberr(space, w_self, 'decorator_list')
     if w_self.w_decorator_list is None:
         if w_self.decorator_list is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'name')
+        raise_attriberr(space, w_self, 'name')
     return space.wrap(w_self.name)
 
 def ClassDef_set_name(space, w_self, w_new_value):
 
 def ClassDef_get_bases(space, w_self):
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'bases')
+        raise_attriberr(space, w_self, 'bases')
     if w_self.w_bases is None:
         if w_self.bases is None:
             list_w = []
 
 def ClassDef_get_body(space, w_self):
     if not w_self.initialization_state & 16:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
+        raise_attriberr(space, w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
 
 def ClassDef_get_decorator_list(space, w_self):
     if not w_self.initialization_state & 32:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'decorator_list')
+        raise_attriberr(space, w_self, 'decorator_list')
     if w_self.w_decorator_list is None:
         if w_self.decorator_list is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
+        raise_attriberr(space, w_self, 'value')
     return space.wrap(w_self.value)
 
 def Return_set_value(space, w_self, w_new_value):
 
 def Delete_get_targets(space, w_self):
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'targets')
+        raise_attriberr(space, w_self, 'targets')
     if w_self.w_targets is None:
         if w_self.targets is None:
             list_w = []
 
 def Assign_get_targets(space, w_self):
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'targets')
+        raise_attriberr(space, w_self, 'targets')
     if w_self.w_targets is None:
         if w_self.targets is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
+        raise_attriberr(space, w_self, 'value')
     return space.wrap(w_self.value)
 
 def Assign_set_value(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'target')
+        raise_attriberr(space, w_self, 'target')
     return space.wrap(w_self.target)
 
 def AugAssign_set_target(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'op')
+        raise_attriberr(space, w_self, 'op')
     return operator_to_class[w_self.op - 1]()
 
 def AugAssign_set_op(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 16:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
+        raise_attriberr(space, w_self, 'value')
     return space.wrap(w_self.value)
 
 def AugAssign_set_value(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'dest')
+        raise_attriberr(space, w_self, 'dest')
     return space.wrap(w_self.dest)
 
 def Print_set_dest(space, w_self, w_new_value):
 
 def Print_get_values(space, w_self):
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'values')
+        raise_attriberr(space, w_self, 'values')
     if w_self.w_values is None:
         if w_self.values is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 16:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'nl')
+        raise_attriberr(space, w_self, 'nl')
     return space.wrap(w_self.nl)
 
 def Print_set_nl(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'target')
+        raise_attriberr(space, w_self, 'target')
     return space.wrap(w_self.target)
 
 def For_set_target(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'iter')
+        raise_attriberr(space, w_self, 'iter')
     return space.wrap(w_self.iter)
 
 def For_set_iter(space, w_self, w_new_value):
 
 def For_get_body(space, w_self):
     if not w_self.initialization_state & 16:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
+        raise_attriberr(space, w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
 
 def For_get_orelse(space, w_self):
     if not w_self.initialization_state & 32:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'orelse')
+        raise_attriberr(space, w_self, 'orelse')
     if w_self.w_orelse is None:
         if w_self.orelse is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'test')
+        raise_attriberr(space, w_self, 'test')
     return space.wrap(w_self.test)
 
 def While_set_test(space, w_self, w_new_value):
 
 def While_get_body(space, w_self):
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
+        raise_attriberr(space, w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
 
 def While_get_orelse(space, w_self):
     if not w_self.initialization_state & 16:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'orelse')
+        raise_attriberr(space, w_self, 'orelse')
     if w_self.w_orelse is None:
         if w_self.orelse is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'test')
+        raise_attriberr(space, w_self, 'test')
     return space.wrap(w_self.test)
 
 def If_set_test(space, w_self, w_new_value):
 
 def If_get_body(space, w_self):
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
+        raise_attriberr(space, w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
 
 def If_get_orelse(space, w_self):
     if not w_self.initialization_state & 16:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'orelse')
+        raise_attriberr(space, w_self, 'orelse')
     if w_self.w_orelse is None:
         if w_self.orelse is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'context_expr')
+        raise_attriberr(space, w_self, 'context_expr')
     return space.wrap(w_self.context_expr)
 
 def With_set_context_expr(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'optional_vars')
+        raise_attriberr(space, w_self, 'optional_vars')
     return space.wrap(w_self.optional_vars)
 
 def With_set_optional_vars(space, w_self, w_new_value):
 
 def With_get_body(space, w_self):
     if not w_self.initialization_state & 16:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
+        raise_attriberr(space, w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'type')
+        raise_attriberr(space, w_self, 'type')
     return space.wrap(w_self.type)
 
 def Raise_set_type(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'inst')
+        raise_attriberr(space, w_self, 'inst')
     return space.wrap(w_self.inst)
 
 def Raise_set_inst(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 16:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'tback')
+        raise_attriberr(space, w_self, 'tback')
     return space.wrap(w_self.tback)
 
 def Raise_set_tback(space, w_self, w_new_value):
 
 def TryExcept_get_body(space, w_self):
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
+        raise_attriberr(space, w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
 
 def TryExcept_get_handlers(space, w_self):
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'handlers')
+        raise_attriberr(space, w_self, 'handlers')
     if w_self.w_handlers is None:
         if w_self.handlers is None:
             list_w = []
 
 def TryExcept_get_orelse(space, w_self):
     if not w_self.initialization_state & 16:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'orelse')
+        raise_attriberr(space, w_self, 'orelse')
     if w_self.w_orelse is None:
         if w_self.orelse is None:
             list_w = []
 
 def TryFinally_get_body(space, w_self):
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
+        raise_attriberr(space, w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
 
 def TryFinally_get_finalbody(space, w_self):
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'finalbody')
+        raise_attriberr(space, w_self, 'finalbody')
     if w_self.w_finalbody is None:
         if w_self.finalbody is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'test')
+        raise_attriberr(space, w_self, 'test')
     return space.wrap(w_self.test)
 
 def Assert_set_test(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'msg')
+        raise_attriberr(space, w_self, 'msg')
     return space.wrap(w_self.msg)
 
 def Assert_set_msg(space, w_self, w_new_value):
 
 def Import_get_names(space, w_self):
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'names')
+        raise_attriberr(space, w_self, 'names')
     if w_self.w_names is None:
         if w_self.names is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'module')
+        raise_attriberr(space, w_self, 'module')
     return space.wrap(w_self.module)
 
 def ImportFrom_set_module(space, w_self, w_new_value):
 
 def ImportFrom_get_names(space, w_self):
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'names')
+        raise_attriberr(space, w_self, 'names')
     if w_self.w_names is None:
         if w_self.names is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 16:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'level')
+        raise_attriberr(space, w_self, 'level')
     return space.wrap(w_self.level)
 
 def ImportFrom_set_level(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
+        raise_attriberr(space, w_self, 'body')
     return space.wrap(w_self.body)
 
 def Exec_set_body(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'globals')
+        raise_attriberr(space, w_self, 'globals')
     return space.wrap(w_self.globals)
 
 def Exec_set_globals(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 16:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'locals')
+        raise_attriberr(space, w_self, 'locals')
     return space.wrap(w_self.locals)
 
 def Exec_set_locals(space, w_self, w_new_value):
 
 def Global_get_names(space, w_self):
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'names')
+        raise_attriberr(space, w_self, 'names')
     if w_self.w_names is None:
         if w_self.names is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
+        raise_attriberr(space, w_self, 'value')
     return space.wrap(w_self.value)
 
 def Expr_set_value(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 1:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'lineno')
+        raise_attriberr(space, w_self, 'lineno')
     return space.wrap(w_self.lineno)
 
 def expr_set_lineno(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 2:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'col_offset')
+        raise_attriberr(space, w_self, 'col_offset')
     return space.wrap(w_self.col_offset)
 
 def expr_set_col_offset(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'op')
+        raise_attriberr(space, w_self, 'op')
     return boolop_to_class[w_self.op - 1]()
 
 def BoolOp_set_op(space, w_self, w_new_value):
 
 def BoolOp_get_values(space, w_self):
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'values')
+        raise_attriberr(space, w_self, 'values')
     if w_self.w_values is None:
         if w_self.values is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'left')
+        raise_attriberr(space, w_self, 'left')
     return space.wrap(w_self.left)
 
 def BinOp_set_left(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'op')
+        raise_attriberr(space, w_self, 'op')
     return operator_to_class[w_self.op - 1]()
 
 def BinOp_set_op(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 16:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'right')
+        raise_attriberr(space, w_self, 'right')
     return space.wrap(w_self.right)
 
 def BinOp_set_right(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'op')
+        raise_attriberr(space, w_self, 'op')
     return unaryop_to_class[w_self.op - 1]()
 
 def UnaryOp_set_op(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'operand')
+        raise_attriberr(space, w_self, 'operand')
     return space.wrap(w_self.operand)
 
 def UnaryOp_set_operand(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'args')
+        raise_attriberr(space, w_self, 'args')
     return space.wrap(w_self.args)
 
 def Lambda_set_args(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
+        raise_attriberr(space, w_self, 'body')
     return space.wrap(w_self.body)
 
 def Lambda_set_body(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'test')
+        raise_attriberr(space, w_self, 'test')
     return space.wrap(w_self.test)
 
 def IfExp_set_test(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
+        raise_attriberr(space, w_self, 'body')
     return space.wrap(w_self.body)
 
 def IfExp_set_body(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 16:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'orelse')
+        raise_attriberr(space, w_self, 'orelse')
     return space.wrap(w_self.orelse)
 
 def IfExp_set_orelse(space, w_self, w_new_value):
 
 def Dict_get_keys(space, w_self):
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'keys')
+        raise_attriberr(space, w_self, 'keys')
     if w_self.w_keys is None:
         if w_self.keys is None:
             list_w = []
 
 def Dict_get_values(space, w_self):
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'values')
+        raise_attriberr(space, w_self, 'values')
     if w_self.w_values is None:
         if w_self.values is None:
             list_w = []
 
 def Set_get_elts(space, w_self):
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'elts')
+        raise_attriberr(space, w_self, 'elts')
     if w_self.w_elts is None:
         if w_self.elts is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'elt')
+        raise_attriberr(space, w_self, 'elt')
     return space.wrap(w_self.elt)
 
 def ListComp_set_elt(space, w_self, w_new_value):
 
 def ListComp_get_generators(space, w_self):
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'generators')
+        raise_attriberr(space, w_self, 'generators')
     if w_self.w_generators is None:
         if w_self.generators is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'elt')
+        raise_attriberr(space, w_self, 'elt')
     return space.wrap(w_self.elt)
 
 def SetComp_set_elt(space, w_self, w_new_value):
 
 def SetComp_get_generators(space, w_self):
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'generators')
+        raise_attriberr(space, w_self, 'generators')
     if w_self.w_generators is None:
         if w_self.generators is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'key')
+        raise_attriberr(space, w_self, 'key')
     return space.wrap(w_self.key)
 
 def DictComp_set_key(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
+        raise_attriberr(space, w_self, 'value')
     return space.wrap(w_self.value)
 
 def DictComp_set_value(space, w_self, w_new_value):
 
 def DictComp_get_generators(space, w_self):
     if not w_self.initialization_state & 16:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'generators')
+        raise_attriberr(space, w_self, 'generators')
     if w_self.w_generators is None:
         if w_self.generators is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'elt')
+        raise_attriberr(space, w_self, 'elt')
     return space.wrap(w_self.elt)
 
 def GeneratorExp_set_elt(space, w_self, w_new_value):
 
 def GeneratorExp_get_generators(space, w_self):
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'generators')
+        raise_attriberr(space, w_self, 'generators')
     if w_self.w_generators is None:
         if w_self.generators is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
+        raise_attriberr(space, w_self, 'value')
     return space.wrap(w_self.value)
 
 def Yield_set_value(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'left')
+        raise_attriberr(space, w_self, 'left')
     return space.wrap(w_self.left)
 
 def Compare_set_left(space, w_self, w_new_value):
 
 def Compare_get_ops(space, w_self):
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'ops')
+        raise_attriberr(space, w_self, 'ops')
     if w_self.w_ops is None:
         if w_self.ops is None:
             list_w = []
 
 def Compare_get_comparators(space, w_self):
     if not w_self.initialization_state & 16:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'comparators')
+        raise_attriberr(space, w_self, 'comparators')
     if w_self.w_comparators is None:
         if w_self.comparators is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'func')
+        raise_attriberr(space, w_self, 'func')
     return space.wrap(w_self.func)
 
 def Call_set_func(space, w_self, w_new_value):
 
 def Call_get_args(space, w_self):
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'args')
+        raise_attriberr(space, w_self, 'args')
     if w_self.w_args is None:
         if w_self.args is None:
             list_w = []
 
 def Call_get_keywords(space, w_self):
     if not w_self.initialization_state & 16:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'keywords')
+        raise_attriberr(space, w_self, 'keywords')
     if w_self.w_keywords is None:
         if w_self.keywords is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 32:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'starargs')
+        raise_attriberr(space, w_self, 'starargs')
     return space.wrap(w_self.starargs)
 
 def Call_set_starargs(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 64:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'kwargs')
+        raise_attriberr(space, w_self, 'kwargs')
     return space.wrap(w_self.kwargs)
 
 def Call_set_kwargs(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
+        raise_attriberr(space, w_self, 'value')
     return space.wrap(w_self.value)
 
 def Repr_set_value(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'n')
+        raise_attriberr(space, w_self, 'n')
     return w_self.n
 
 def Num_set_n(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 's')
+        raise_attriberr(space, w_self, 's')
     return w_self.s
 
 def Str_set_s(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
+        raise_attriberr(space, w_self, 'value')
     return space.wrap(w_self.value)
 
 def Attribute_set_value(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'attr')
+        raise_attriberr(space, w_self, 'attr')
     return space.wrap(w_self.attr)
 
 def Attribute_set_attr(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 16:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'ctx')
+        raise_attriberr(space, w_self, 'ctx')
     return expr_context_to_class[w_self.ctx - 1]()
 
 def Attribute_set_ctx(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
+        raise_attriberr(space, w_self, 'value')
     return space.wrap(w_self.value)
 
 def Subscript_set_value(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'slice')
+        raise_attriberr(space, w_self, 'slice')
     return space.wrap(w_self.slice)
 
 def Subscript_set_slice(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 16:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'ctx')
+        raise_attriberr(space, w_self, 'ctx')
     return expr_context_to_class[w_self.ctx - 1]()
 
 def Subscript_set_ctx(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'id')
+        raise_attriberr(space, w_self, 'id')
     return space.wrap(w_self.id)
 
 def Name_set_id(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'ctx')
+        raise_attriberr(space, w_self, 'ctx')
     return expr_context_to_class[w_self.ctx - 1]()
 
 def Name_set_ctx(space, w_self, w_new_value):
 
 def List_get_elts(space, w_self):
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'elts')
+        raise_attriberr(space, w_self, 'elts')
     if w_self.w_elts is None:
         if w_self.elts is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'ctx')
+        raise_attriberr(space, w_self, 'ctx')
     return expr_context_to_class[w_self.ctx - 1]()
 
 def List_set_ctx(space, w_self, w_new_value):
 
 def Tuple_get_elts(space, w_self):
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'elts')
+        raise_attriberr(space, w_self, 'elts')
     if w_self.w_elts is None:
         if w_self.elts is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'ctx')
+        raise_attriberr(space, w_self, 'ctx')
     return expr_context_to_class[w_self.ctx - 1]()
 
 def Tuple_set_ctx(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
+        raise_attriberr(space, w_self, 'value')
     return w_self.value
 
 def Const_set_value(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 1:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'lower')
+        raise_attriberr(space, w_self, 'lower')
     return space.wrap(w_self.lower)
 
 def Slice_set_lower(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 2:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'upper')
+        raise_attriberr(space, w_self, 'upper')
     return space.wrap(w_self.upper)
 
 def Slice_set_upper(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'step')
+        raise_attriberr(space, w_self, 'step')
     return space.wrap(w_self.step)
 
 def Slice_set_step(space, w_self, w_new_value):
 
 def ExtSlice_get_dims(space, w_self):
     if not w_self.initialization_state & 1:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'dims')
+        raise_attriberr(space, w_self, 'dims')
     if w_self.w_dims is None:
         if w_self.dims is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 1:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
+        raise_attriberr(space, w_self, 'value')
     return space.wrap(w_self.value)
 
 def Index_set_value(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 1:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'target')
+        raise_attriberr(space, w_self, 'target')
     return space.wrap(w_self.target)
 
 def comprehension_set_target(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 2:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'iter')
+        raise_attriberr(space, w_self, 'iter')
     return space.wrap(w_self.iter)
 
 def comprehension_set_iter(space, w_self, w_new_value):
 
 def comprehension_get_ifs(space, w_self):
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'ifs')
+        raise_attriberr(space, w_self, 'ifs')
     if w_self.w_ifs is None:
         if w_self.ifs is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 1:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'lineno')
+        raise_attriberr(space, w_self, 'lineno')
     return space.wrap(w_self.lineno)
 
 def excepthandler_set_lineno(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 2:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'col_offset')
+        raise_attriberr(space, w_self, 'col_offset')
     return space.wrap(w_self.col_offset)
 
 def excepthandler_set_col_offset(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'type')
+        raise_attriberr(space, w_self, 'type')
     return space.wrap(w_self.type)
 
 def ExceptHandler_set_type(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'name')
+        raise_attriberr(space, w_self, 'name')
     return space.wrap(w_self.name)
 
 def ExceptHandler_set_name(space, w_self, w_new_value):
 
 def ExceptHandler_get_body(space, w_self):
     if not w_self.initialization_state & 16:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
+        raise_attriberr(space, w_self, 'body')
     if w_self.w_body is None:
         if w_self.body is None:
             list_w = []
 
 def arguments_get_args(space, w_self):
     if not w_self.initialization_state & 1:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'args')
+        raise_attriberr(space, w_self, 'args')
     if w_self.w_args is None:
         if w_self.args is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 2:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'vararg')
+        raise_attriberr(space, w_self, 'vararg')
     return space.wrap(w_self.vararg)
 
 def arguments_set_vararg(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 4:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'kwarg')
+        raise_attriberr(space, w_self, 'kwarg')
     return space.wrap(w_self.kwarg)
 
 def arguments_set_kwarg(space, w_self, w_new_value):
 
 def arguments_get_defaults(space, w_self):
     if not w_self.initialization_state & 8:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'defaults')
+        raise_attriberr(space, w_self, 'defaults')
     if w_self.w_defaults is None:
         if w_self.defaults is None:
             list_w = []
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 1:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'arg')
+        raise_attriberr(space, w_self, 'arg')
     return space.wrap(w_self.arg)
 
 def keyword_set_arg(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 2:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
+        raise_attriberr(space, w_self, 'value')
     return space.wrap(w_self.value)
 
 def keyword_set_value(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 1:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'name')
+        raise_attriberr(space, w_self, 'name')
     return space.wrap(w_self.name)
 
 def alias_set_name(space, w_self, w_new_value):
         if w_obj is not None:
             return w_obj
     if not w_self.initialization_state & 2:
-        raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'asname')
+        raise_attriberr(space, w_self, 'asname')
     return space.wrap(w_self.asname)
 
 def alias_set_asname(space, w_self, w_new_value):

pypy/interpreter/astcompiler/tools/asdl_py.py

             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("raise operationerrfmt(space.w_AttributeError, \"'%%T' object has no attribute '%%s'\", w_self, '%s')" %
-                  (field.name,), 2)
+        self.emit("raise_attriberr(space, w_self, '%s')" % (field.name,), 2)
         if field.seq:
             self.emit("if w_self.w_%s is None:" % (field.name,), 1)
             self.emit("if w_self.%s is None:" % (field.name,), 2)
 
 
 HEAD = """# Generated by tools/asdl_py.py
-from pypy.interpreter.baseobjspace import W_Root
-from pypy.interpreter import typedef
-from pypy.interpreter.gateway import interp2app
-from pypy.interpreter.error import OperationError, operationerrfmt
 from rpython.rlib.unroll import unrolling_iterable
 from rpython.tool.pairtype import extendabletype
 from rpython.tool.sourcetools import func_with_new_name
 
+from pypy.interpreter import typedef
+from pypy.interpreter.baseobjspace import W_Root
+from pypy.interpreter.error import OperationError, oefmt
+from pypy.interpreter.gateway import interp2app
+
+
+def raise_attriberr(space, w_obj, name):
+    raise oefmt(space.w_AttributeError,
+                \"'%T' object has no attribute '%s'\", w_obj, name)
+
 
 def check_string(space, w_obj):
     if not (space.isinstance_w(w_obj, space.w_str) or
                 continue  # field is optional
             w_obj = self.getdictvalue(space, missing)
             if w_obj is None:
-                err = "required field \\"%s\\" missing from %s"
-                raise operationerrfmt(space.w_TypeError, err, missing, host)
+                raise oefmt(space.w_TypeError,
+                            "required field \\"%s\\" missing from %s",
+                            missing, host)
             else:
-                err = "incorrect type for field \\"%s\\" in %s"
-                raise operationerrfmt(space.w_TypeError, err, missing, host)
+                raise oefmt(space.w_TypeError,
+                            "incorrect type for field \\"%s\\" in %s",
+                            missing, host)
         raise AssertionError("should not reach here")
 
 

pypy/interpreter/baseobjspace.py

 
 from pypy.interpreter.executioncontext import (ExecutionContext, ActionFlag,
     UserDelAction)
-from pypy.interpreter.error import (OperationError, operationerrfmt,
-    new_exception_class)
+from pypy.interpreter.error import OperationError, new_exception_class, oefmt
 from pypy.interpreter.argument import Arguments
 from pypy.interpreter.miscutils import ThreadLocals
 
         return False
 
     def setdict(self, space, w_dict):
-        raise operationerrfmt(space.w_TypeError,
-                              "attribute '__dict__' of %T objects "
-                              "is not writable", self)
+        raise oefmt(space.w_TypeError,
+                     "attribute '__dict__' of %T objects is not writable",
+                     self)
 
     # to be used directly only by space.type implementations
     def getclass(self, space):
             classname = '?'
         else:
             classname = wrappable_class_name(RequiredClass)
-        msg = "'%s' object expected, got '%T' instead"
-        raise operationerrfmt(space.w_TypeError, msg, classname, self)
+        raise oefmt(space.w_TypeError,
+                    "'%s' object expected, got '%T' instead", classname, self)
 
     # used by _weakref implemenation
 
         return None
 
     def setweakref(self, space, weakreflifeline):
-        raise operationerrfmt(space.w_TypeError,
-            "cannot create weak reference to '%T' object", self)
+        raise oefmt(space.w_TypeError,
+                    "cannot create weak reference to '%T' object", self)
 
     def delweakref(self):
         pass
         self._typed_unwrap_error(space, "integer")
 
     def _typed_unwrap_error(self, space, expected):
-        raise operationerrfmt(space.w_TypeError, "expected %s, got %T object",
-                              expected, self)
+        raise oefmt(space.w_TypeError,
+                    "expected %s, got %T object", expected, self)
 
     def int(self, space):
         w_impl = space.lookup(self, '__int__')
         if w_impl is None:
-            raise operationerrfmt(space.w_TypeError,
-                  "unsupported operand type for int(): '%T'", self)
+            raise oefmt(space.w_TypeError,
+                        "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
-        msg = "__int__ returned non-int (type '%T')"
-        raise operationerrfmt(space.w_TypeError, msg, w_result)
+        raise oefmt(space.w_TypeError,
+                    "__int__ returned non-int (type '%T')", w_result)
 
     def ord(self, space):
-        msg = "ord() expected string of length 1, but %T found"
-        raise operationerrfmt(space.w_TypeError, msg, self)
+        raise oefmt(space.w_TypeError,
+                    "ord() expected string of length 1, but %T found", self)
 
     def __spacebind__(self, space):
         return self
         try:
             w_mod = self.builtin_modules[name]
         except KeyError:
-            raise operationerrfmt(
-                self.w_SystemError,
-                "getbuiltinmodule() called "
-                "with non-builtin module %s", name)
+            raise oefmt(self.w_SystemError,
+                        "getbuiltinmodule() called with non-builtin module %s",
+                        name)
         else:
             # Add the module to sys.modules
             self.setitem(w_modules, w_name, w_mod)
         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 '%N' instead"
-            raise operationerrfmt(self.w_TypeError, msg,
-                wrappable_class_name(RequiredClass), w_obj.getclass(self))
+            raise oefmt(self.w_TypeError,
+                        "'%s' object expected, got '%N' instead",
+                        wrappable_class_name(RequiredClass),
+                        w_obj.getclass(self))
         return w_obj
     interp_w._annspecialcase_ = 'specialize:arg(1)'
 
             items[idx] = w_item
             idx += 1
         if idx < expected_length:
-            if idx == 1:
-                plural = ""
-            else:
-                plural = "s"
-            raise operationerrfmt(self.w_ValueError,
-                                  "need more than %d value%s to unpack",
-                                  idx, plural)
+            raise oefmt(self.w_ValueError,
+                        "need more than %d value%s to unpack",
+                        idx, "" if idx == 1 else "s")
         return items
 
     def unpackiterable_unroll(self, w_iterable, expected_length):
         except OperationError, err:
             if objdescr is None or not err.match(self, self.w_TypeError):
                 raise
-            msg = "%s must be an integer, not %T"
-            raise operationerrfmt(self.w_TypeError, msg, objdescr, w_obj)
+            raise oefmt(self.w_TypeError, "%s must be an integer, not %T",
+                        objdescr, w_obj)
         try:
             index = self.int_w(w_index)
         except OperationError, err:
                 else:
                     return sys.maxint
             else:
-                raise operationerrfmt(
-                    w_exception, "cannot fit '%T' into an index-sized integer",
-                    w_obj)
+                raise oefmt(w_exception,
+                            "cannot fit '%T' into an index-sized integer",
+                            w_obj)
         else:
             return index
 
                 )
         fd = self.int_w(w_fd)
         if fd < 0:
-            raise operationerrfmt(self.w_ValueError,
-                "file descriptor cannot be a negative integer (%d)", fd
-            )
+            raise oefmt(self.w_ValueError,
+                        "file descriptor cannot be a negative integer (%d)",
+                        fd)
         return fd
 
     def warn(self, w_msg, w_warningcls, stacklevel=2):

pypy/interpreter/error.py

     def _exception_getclass(self, space, w_inst):
         w_type = space.exception_getclass(w_inst)
         if not space.exception_is_valid_class_w(w_type):
-            msg = ("exceptions must be old-style classes or derived "
-                   "from BaseException, not %N")
-            raise operationerrfmt(space.w_TypeError, msg, w_type)
+            raise oefmt(space.w_TypeError,
+                        "exceptions must be old-style classes or derived from "
+                        "BaseException, not %N", w_type)
         return w_type
 
     def write_unraisable(self, space, where, w_object=None,
             self._w_value = w_value = space.wrap(self._value)
         return w_value
 
-def get_operationerr_class(valuefmt):
+@specialize.memo()
+def get_operr_class(valuefmt):
     try:
         result = _fmtcache[valuefmt]
     except KeyError:
         result = _fmtcache[valuefmt] = get_operrcls2(valuefmt)
     return result
-get_operationerr_class._annspecialcase_ = 'specialize:memo'
 
-def operationerrfmt(w_type, valuefmt, *args):
+@specialize.arg(1)
+def oefmt(w_type, valuefmt, *args):
     """Equivalent to OperationError(w_type, space.wrap(valuefmt % args)).
     More efficient in the (common) case where the value is not actually
     needed.
     """
     if not len(args):
         return OpErrFmtNoArgs(w_type, valuefmt)
-    OpErrFmt, strings = get_operationerr_class(valuefmt)
+    OpErrFmt, strings = get_operr_class(valuefmt)
     return OpErrFmt(w_type, strings, *args)
-operationerrfmt._annspecialcase_ = 'specialize:arg(1)'
 
 # ____________________________________________________________
 

pypy/interpreter/function.py

 """
 
 from rpython.rlib.unroll import unrolling_iterable
-from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.interpreter.baseobjspace import W_Root
+from pypy.interpreter.error import OperationError, oefmt
 from pypy.interpreter.eval import Code
 from pypy.interpreter.argument import Arguments
 from rpython.rlib import jit
         if self.closure:
             closure_len = len(self.closure)
         if isinstance(code, PyCode) and closure_len != len(code.co_freevars):
-            raise operationerrfmt(space.w_ValueError,
-                "%N() requires a code object with %d free vars, not %d",
-                self, closure_len, len(code.co_freevars))
+            raise oefmt(space.w_ValueError,
+                        "%N() requires a code object with %d free vars, not "
+                        "%d", self, closure_len, len(code.co_freevars))
         self.fget_func_doc(space)    # see test_issue1293
         self.code = code
 
                     instdescr = instname + " instance"
                 else:
                     instdescr = "instance"
-            msg = ("unbound method %N() must be called with %s "
-                   "as first argument (got %s instead)")
-            raise operationerrfmt(space.w_TypeError, msg,
-                                  self, clsdescr, instdescr)
+            raise oefmt(space.w_TypeError,
+                        "unbound method %N() must be called with %s as first "
+                        "argument (got %s instead)", self, clsdescr, instdescr)
         return space.call_args(self.w_function, args)
 
     def descr_method_get(self, w_obj, w_cls=None):

pypy/interpreter/pyframe.py

 from pypy.interpreter.argument import Arguments
 from pypy.interpreter.astcompiler import consts
 from pypy.interpreter.baseobjspace import W_Root
-from pypy.interpreter.error import OperationError, operationerrfmt
+from pypy.interpreter.error import OperationError, oefmt
 from pypy.interpreter.executioncontext import ExecutionContext
 from pypy.interpreter.nestedscope import Cell
 from pypy.tool import stdlib_opcode
 
         line = self.pycode.co_firstlineno
         if new_lineno < line:
-            raise operationerrfmt(space.w_ValueError,
-                  "line %d comes before the current code.", new_lineno)
+            raise oefmt(space.w_ValueError,
+                        "line %d comes before the current code.", new_lineno)
         elif new_lineno == line:
             new_lasti = 0
         else:
                     break
 
         if new_lasti == -1:
-            raise operationerrfmt(space.w_ValueError,
-                  "line %d comes after the current code.", new_lineno)
+            raise oefmt(space.w_ValueError,
+                        "line %d comes after the current code.", new_lineno)
 
         # Don't jump to a line with an except in it.
         code = self.pycode.co_code
         assert len(blockstack) == 0
 
         if new_lasti_setup_addr != f_lasti_setup_addr:
-            raise operationerrfmt(space.w_ValueError,
-                  "can't jump into or out of a 'finally' block %d -> %d",
-                  f_lasti_setup_addr, new_lasti_setup_addr)
+            raise oefmt(space.w_ValueError,
+                        "can't jump into or out of a 'finally' block %d -> %d",
+                        f_lasti_setup_addr, new_lasti_setup_addr)
 
         if new_lasti < self.last_instr:
             min_addr = new_lasti

pypy/interpreter/pyopcode.py

     gateway, function, eval, pyframe, pytraceback, pycode
 )
 from pypy.interpreter.baseobjspace import W_Root
-from pypy.interpreter.error import OperationError, operationerrfmt
+from pypy.interpreter.error import OperationError, oefmt
 from pypy.interpreter.nestedscope import Cell
 from pypy.interpreter.pycode import PyCode, BytecodeCorruption
 from pypy.tool.stdlib_opcode import bytecode_spec
 
     def _load_fast_failed(self, varindex):
         varname = self.getlocalvarname(varindex)
-        message = "local variable '%s' referenced before assignment"
-        raise operationerrfmt(self.space.w_UnboundLocalError, message, varname)
+        raise oefmt(self.space.w_UnboundLocalError,
+                    "local variable '%s' referenced before assignment",
+                    varname)
     _load_fast_failed._dont_inline_ = True
 
     def LOAD_CONST(self, constindex, next_instr):
             # catch KeyErrors and turn them into NameErrors
             if not e.match(self.space, self.space.w_KeyError):
                 raise
-            message = "name '%s' is not defined"
-            raise operationerrfmt(self.space.w_NameError, message,
-                                  self.space.str_w(w_varname))
+            raise oefmt(self.space.w_NameError, "name '%s' is not defined",
+                        self.space.str_w(w_varname))
 
     def UNPACK_SEQUENCE(self, itemcount, next_instr):
         w_iterable = self.popvalue()
     _load_global._always_inline_ = True
 
     def _load_global_failed(self, varname):
-        message = "global name '%s' is not defined"
-        raise operationerrfmt(self.space.w_NameError, message, varname)
+        raise oefmt(self.space.w_NameError,
+                    "global name '%s' is not defined", varname)
     _load_global_failed._dont_inline_ = True
 
     def LOAD_GLOBAL(self, nameindex, next_instr):
     def DELETE_FAST(self, varindex, next_instr):
         if self.locals_stack_w[varindex] is None:
             varname = self.getlocalvarname(varindex)
-            message = "local variable '%s' referenced before assignment"
-            raise operationerrfmt(self.space.w_UnboundLocalError, message,
-                                  varname)
+            raise oefmt(self.space.w_UnboundLocalError,
+                        "local variable '%s' referenced before assignment",
+                        varname)
         self.locals_stack_w[varindex] = None
 
     def BUILD_TUPLE(self, itemcount, next_instr):
         except OperationError, e:
             if not e.match(self.space, self.space.w_AttributeError):
                 raise
-            raise operationerrfmt(self.space.w_ImportError,
-                                  "cannot import name '%s'",
-                                  self.space.str_w(w_name))
+            raise oefmt(self.space.w_ImportError,
+                        "cannot import name '%s'", self.space.str_w(w_name))
         self.pushvalue(w_obj)
 
     def YIELD_VALUE(self, oparg, next_instr):
         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:
-            raise operationerrfmt(self.space.w_AttributeError,
-                "'%T' object is not a context manager"
-                " (no __enter__/__exit__ method)", w_manager)
+            raise oefmt(self.space.w_AttributeError,
+                        "'%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)

pypy/interpreter/test/test_error.py

 import py, os, errno
-from pypy.interpreter.error import OperationError, operationerrfmt
-from pypy.interpreter.error import decompose_valuefmt, get_operrcls2
-from pypy.interpreter.error import wrap_oserror, new_exception_class
+from pypy.interpreter.error import (
+    OperationError, decompose_valuefmt, get_operrcls2, new_exception_class,
+    oefmt, wrap_oserror)
 
 
 def test_decompose_valuefmt():
     assert cls2 is cls     # caching
     assert strings2 == ("a ", " b ", " c")
 
-def test_operationerrfmt(space):
-    operr = operationerrfmt("w_type", "abc %s def %d", "foo", 42)
+def test_oefmt(space):
+    operr = oefmt("w_type", "abc %s def %d", "foo", 42)
     assert isinstance(operr, OperationError)
     assert operr.w_type == "w_type"
     assert operr._w_value is None
     assert operr._compute_value(space) == "abc foo def 42"
-    operr2 = operationerrfmt("w_type2", "a %s b %d c", "bar", 43)
+    operr2 = oefmt("w_type2", "a %s b %d c", "bar", 43)
     assert operr2.__class__ is operr.__class__
-    operr3 = operationerrfmt("w_type2", "a %s b %s c", "bar", "4b")
+    operr3 = oefmt("w_type2", "a %s b %s c", "bar", "4b")
     assert operr3.__class__ is not operr.__class__
 
-def test_operationerrfmt_noargs(space):
-    operr = operationerrfmt(space.w_AttributeError, "no attribute 'foo'")
+def test_oefmt_noargs(space):
+    operr = oefmt(space.w_AttributeError, "no attribute 'foo'")
     operr.normalize_exception(space)
     val = operr.get_w_value(space)
     assert space.isinstance_w(val, space.w_AttributeError)
     w_repr = space.repr(val)
     assert space.str_w(w_repr) == "AttributeError(\"no attribute 'foo'\",)"
 
-def test_operationerrfmt_T(space):
-    operr = operationerrfmt(space.w_AttributeError,
-                            "'%T' object has no attribute '%s'",
-                            space.wrap('foo'), 'foo')
+def test_oefmt_T(space):
+    operr = oefmt(space.w_AttributeError,
+                  "'%T' object has no attribute '%s'",
+                  space.wrap('foo'), 'foo')
     assert operr._compute_value(space) == "'str' object has no attribute 'foo'"
-    operr = operationerrfmt("w_type",
-                            "'%T' object has no attribute '%s'",
-                            space.wrap('foo'), 'foo')
+    operr = oefmt("w_type",
+                  "'%T' object has no attribute '%s'",
+                  space.wrap('foo'), 'foo')
     assert operr._compute_value(space) == "'str' object has no attribute 'foo'"
 
-def test_operationerrfmt_N(space):
-    operr = operationerrfmt(space.w_AttributeError,
-                            "'%N' object has no attribute '%s'",
-                            space.type(space.wrap('foo')), 'foo')
+def test_oefmt_N(space):
+    operr = oefmt(space.w_AttributeError,
+                  "'%N' object has no attribute '%s'",
+                  space.type(space.wrap('foo')), 'foo')
     assert operr._compute_value(space) == "'str' object has no attribute 'foo'"
-    operr = operationerrfmt("w_type",
-                            "'%N' object has no attribute '%s'",
-                            space.type(space.wrap('foo')), 'foo')
+    operr = oefmt("w_type",
+                  "'%N' object has no attribute '%s'",
+                  space.type(space.wrap('foo')), 'foo')
     assert operr._compute_value(space) == "'str' object has no attribute 'foo'"
-    operr = operationerrfmt(space.w_AttributeError,
-                            "'%N' object has no attribute '%s'",
-                            space.wrap('foo'), 'foo')
+    operr = oefmt(space.w_AttributeError,
+                  "'%N' object has no attribute '%s'",
+                  space.wrap('foo'), 'foo')
     assert operr._compute_value(space) == "'?' object has no attribute 'foo'"
-    operr = operationerrfmt("w_type",
-                            "'%N' object has no attribute '%s'",
-                            space.wrap('foo'), 'foo')
+    operr = oefmt("w_type",
+                  "'%N' object has no attribute '%s'",
+                  space.wrap('foo'), 'foo')
     assert operr._compute_value(space) == "'?' object has no attribute 'foo'"
 
-def test_operationerrfmt_R(space):
-    operr = operationerrfmt(space.w_ValueError, "illegal newline value: %R",
-                            space.wrap('foo'))
+def test_oefmt_R(space):
+    operr = oefmt(space.w_ValueError,
+                  "illegal newline value: %R", space.wrap('foo'))
     assert operr._compute_value(space) == "illegal newline value: 'foo'"
-    operr = operationerrfmt(space.w_ValueError, "illegal newline value: %R",
-                            space.wrap("'PyLadies'"))
+    operr = oefmt(space.w_ValueError, "illegal newline value: %R",
+                  space.wrap("'PyLadies'"))
     expected = "illegal newline value: \"'PyLadies'\""
     assert operr._compute_value(space) == expected
 

pypy/interpreter/typedef.py

 
 from pypy.interpreter.argument import Arguments
 from pypy.interpreter.baseobjspace import W_Root, DescrMismatch
-from pypy.interpreter.error import OperationError, operationerrfmt
+from pypy.interpreter.error import OperationError, oefmt
 from pypy.interpreter.gateway import (interp2app, BuiltinCode, unwrap_spec,
      WrappedDefault)
 
 
     def typecheck(self, space, w_obj):
         if not space.isinstance_w(w_obj, self.w_cls):
-            m = "descriptor '%N' for '%N' objects doesn't apply to '%T' object"
-            raise operationerrfmt(space.w_TypeError, m,
-                                  self, self.w_cls, w_obj)
+            raise oefmt(space.w_TypeError,
+                        "descriptor '%N' for '%N' objects doesn't apply to "
+                        "'%T' object", self, self.w_cls, w_obj)
 
     def descr_member_get(self, space, w_obj, w_cls=None):
         """member.__get__(obj[, type]) -> value
 def descr_get_dict(space, w_obj):
     w_dict = w_obj.getdict(space)