[pypy-commit] pypy precompiled-headers: merge default into branch

mattip noreply at buildbot.pypy.org
Tue Feb 4 06:02:30 CET 2014


Author: Matti Picus <matti.picus at gmail.com>
Branch: precompiled-headers
Changeset: r69079:dd07756a34a4
Date: 2014-02-04 07:01 +0200
http://bitbucket.org/pypy/pypy/changeset/dd07756a34a4/

Log:	merge default into branch

diff too long, truncating to 2000 out of 6294 lines

diff --git a/dotviewer/graphdisplay.py b/dotviewer/graphdisplay.py
--- a/dotviewer/graphdisplay.py
+++ b/dotviewer/graphdisplay.py
@@ -136,6 +136,7 @@
         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
 
 
@@ -613,6 +614,19 @@
     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)
diff --git a/pypy/interpreter/argument.py b/pypy/interpreter/argument.py
--- a/pypy/interpreter/argument.py
+++ b/pypy/interpreter/argument.py
@@ -1,11 +1,11 @@
 """
 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):
     """
@@ -86,9 +86,9 @@
             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
 
@@ -113,10 +113,9 @@
                 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)
@@ -281,8 +280,7 @@
             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):
@@ -304,8 +302,7 @@
         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):
@@ -344,10 +341,9 @@
     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):
@@ -367,10 +363,9 @@
                 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
diff --git a/pypy/interpreter/astcompiler/ast.py b/pypy/interpreter/astcompiler/ast.py
--- a/pypy/interpreter/astcompiler/ast.py
+++ b/pypy/interpreter/astcompiler/ast.py
@@ -1,12 +1,18 @@
 # 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
@@ -70,11 +76,13 @@
                 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")
 
 
@@ -2793,7 +2801,7 @@
 
 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 = []
@@ -2834,7 +2842,7 @@
 
 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 = []
@@ -2879,7 +2887,7 @@
         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):
@@ -2922,7 +2930,7 @@
 
 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 = []
@@ -2967,7 +2975,7 @@
         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):
@@ -2988,7 +2996,7 @@
         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):
@@ -3018,7 +3026,7 @@
         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):
@@ -3039,7 +3047,7 @@
         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):
@@ -3056,7 +3064,7 @@
 
 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 = []
@@ -3072,7 +3080,7 @@
 
 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 = []
@@ -3121,7 +3129,7 @@
         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):
@@ -3138,7 +3146,7 @@
 
 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 = []
@@ -3154,7 +3162,7 @@
 
 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 = []
@@ -3170,7 +3178,7 @@
 
 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 = []
@@ -3220,7 +3228,7 @@
         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):
@@ -3263,7 +3271,7 @@
 
 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 = []
@@ -3304,7 +3312,7 @@
 
 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 = []
@@ -3324,7 +3332,7 @@
         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):
@@ -3373,7 +3381,7 @@
         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):
@@ -3396,7 +3404,7 @@
         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):
@@ -3419,7 +3427,7 @@
         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):
@@ -3468,7 +3476,7 @@
         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):
@@ -3487,7 +3495,7 @@
 
 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 = []
@@ -3507,7 +3515,7 @@
         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):
@@ -3555,7 +3563,7 @@
         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):
@@ -3578,7 +3586,7 @@
         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):
@@ -3597,7 +3605,7 @@
 
 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 = []
@@ -3613,7 +3621,7 @@
 
 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 = []
@@ -3662,7 +3670,7 @@
         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):
@@ -3681,7 +3689,7 @@
 
 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 = []
@@ -3697,7 +3705,7 @@
 
 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 = []
@@ -3745,7 +3753,7 @@
         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):
@@ -3764,7 +3772,7 @@
 
 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 = []
@@ -3780,7 +3788,7 @@
 
 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 = []
@@ -3828,7 +3836,7 @@
         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):
@@ -3851,7 +3859,7 @@
         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):
@@ -3870,7 +3878,7 @@
 
 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 = []
@@ -3917,7 +3925,7 @@
         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):
@@ -3940,7 +3948,7 @@
         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):
@@ -3963,7 +3971,7 @@
         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):
@@ -4008,7 +4016,7 @@
 
 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 = []
@@ -4024,7 +4032,7 @@
 
 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 = []
@@ -4040,7 +4048,7 @@
 
 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 = []
@@ -4085,7 +4093,7 @@
 
 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 = []
@@ -4101,7 +4109,7 @@
 
 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 = []
@@ -4148,7 +4156,7 @@
         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):
@@ -4171,7 +4179,7 @@
         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):
@@ -4215,7 +4223,7 @@
 
 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 = []
@@ -4260,7 +4268,7 @@
         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):
@@ -4280,7 +4288,7 @@
 
 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 = []
@@ -4300,7 +4308,7 @@
         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):
@@ -4348,7 +4356,7 @@
         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):
@@ -4371,7 +4379,7 @@
         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):
@@ -4394,7 +4402,7 @@
         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):
@@ -4439,7 +4447,7 @@
 
 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 = []
@@ -4484,7 +4492,7 @@
         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):
@@ -4582,7 +4590,7 @@
         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):
@@ -4603,7 +4611,7 @@
         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):
@@ -4633,7 +4641,7 @@
         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):
@@ -4652,7 +4660,7 @@
 
 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 = []
@@ -4698,7 +4706,7 @@
         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):
@@ -4721,7 +4729,7 @@
         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):
@@ -4744,7 +4752,7 @@
         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):
@@ -4793,7 +4801,7 @@
         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):
@@ -4816,7 +4824,7 @@
         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):
@@ -4864,7 +4872,7 @@
         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):
@@ -4885,7 +4893,7 @@
         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):
@@ -4933,7 +4941,7 @@
         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):
@@ -4956,7 +4964,7 @@
         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):
@@ -4979,7 +4987,7 @@
         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):
@@ -5024,7 +5032,7 @@
 
 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 = []
@@ -5040,7 +5048,7 @@
 
 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 = []
@@ -5083,7 +5091,7 @@
 
 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 = []
@@ -5128,7 +5136,7 @@
         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):
@@ -5147,7 +5155,7 @@
 
 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 = []
@@ -5193,7 +5201,7 @@
         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):
@@ -5212,7 +5220,7 @@
 
 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 = []
@@ -5258,7 +5266,7 @@
         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):
@@ -5281,7 +5289,7 @@
         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):
@@ -5300,7 +5308,7 @@
 
 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 = []
@@ -5347,7 +5355,7 @@
         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):
@@ -5366,7 +5374,7 @@
 
 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 = []
@@ -5412,7 +5420,7 @@
         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):
@@ -5459,7 +5467,7 @@
         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):
@@ -5478,7 +5486,7 @@
 
 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 = []
@@ -5494,7 +5502,7 @@
 
 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 = []
@@ -5542,7 +5550,7 @@
         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):
@@ -5561,7 +5569,7 @@
 
 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 = []
@@ -5577,7 +5585,7 @@
 
 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 = []
@@ -5597,7 +5605,7 @@
         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):
@@ -5620,7 +5628,7 @@
         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):
@@ -5673,7 +5681,7 @@
         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):
@@ -5720,7 +5728,7 @@
         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):
@@ -5765,7 +5773,7 @@
         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):
@@ -5810,7 +5818,7 @@
         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):
@@ -5833,7 +5841,7 @@
         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):
@@ -5854,7 +5862,7 @@
         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):
@@ -5903,7 +5911,7 @@
         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):
@@ -5926,7 +5934,7 @@
         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):
@@ -5949,7 +5957,7 @@
         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):
@@ -5998,7 +6006,7 @@
         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):
@@ -6019,7 +6027,7 @@
         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):
@@ -6063,7 +6071,7 @@
 
 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 = []
@@ -6083,7 +6091,7 @@
         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):
@@ -6128,7 +6136,7 @@
 
 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 = []
@@ -6148,7 +6156,7 @@
         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):
@@ -6197,7 +6205,7 @@
         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):
@@ -6315,7 +6323,7 @@
         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):
@@ -6338,7 +6346,7 @@
         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):
@@ -6361,7 +6369,7 @@
         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):
@@ -6406,7 +6414,7 @@
 
 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 = []
@@ -6451,7 +6459,7 @@
         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):
@@ -6722,7 +6730,7 @@
         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):
@@ -6745,7 +6753,7 @@
         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):
@@ -6764,7 +6772,7 @@
 
 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 = []
@@ -6811,7 +6819,7 @@
         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):
@@ -6832,7 +6840,7 @@
         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):
@@ -6862,7 +6870,7 @@
         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):
@@ -6885,7 +6893,7 @@
         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):
@@ -6904,7 +6912,7 @@
 
 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 = []
@@ -6947,7 +6955,7 @@
 
 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 = []
@@ -6967,7 +6975,7 @@
         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):
@@ -6991,7 +6999,7 @@
         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):
@@ -7011,7 +7019,7 @@
 
 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 = []
@@ -7060,7 +7068,7 @@
         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):
@@ -7081,7 +7089,7 @@
         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):
@@ -7129,7 +7137,7 @@
         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):
@@ -7150,7 +7158,7 @@
         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):
diff --git a/pypy/interpreter/astcompiler/tools/asdl_py.py b/pypy/interpreter/astcompiler/tools/asdl_py.py
--- a/pypy/interpreter/astcompiler/tools/asdl_py.py
+++ b/pypy/interpreter/astcompiler/tools/asdl_py.py
@@ -409,8 +409,7 @@
             self.emit("    if w_obj is not None:", 1)
             self.emit("        return w_obj", 1)
         self.emit("if not w_self.initialization_state & %s:" % (flag,), 1)
-        self.emit("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)
@@ -537,14 +536,20 @@
 
 
 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
@@ -608,11 +613,13 @@
                 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")
 
 
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -11,8 +11,7 @@
 
 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
 
@@ -61,9 +60,9 @@
         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):
@@ -123,8 +122,8 @@
             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
 
@@ -132,8 +131,8 @@
         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
@@ -215,25 +214,25 @@
         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
@@ -430,10 +429,9 @@
         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)
@@ -753,9 +751,10 @@
         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)'
 
@@ -832,13 +831,9 @@
             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):
@@ -1257,8 +1252,8 @@
         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:
@@ -1271,9 +1266,9 @@
                 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
 
@@ -1517,9 +1512,9 @@
                 )
         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):
diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py
--- a/pypy/interpreter/error.py
+++ b/pypy/interpreter/error.py
@@ -226,9 +226,9 @@
     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,
@@ -383,15 +383,16 @@
             self._w_value = w_value = space.wrap(self._value)
         return w_value
 
-def get_operationerr_class(valuefmt):
+ at 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):
+ at 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.
@@ -405,9 +406,8 @@
     """
     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)'
 
 # ____________________________________________________________
 
diff --git a/pypy/interpreter/function.py b/pypy/interpreter/function.py
--- a/pypy/interpreter/function.py
+++ b/pypy/interpreter/function.py
@@ -7,8 +7,8 @@
 """
 
 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
@@ -413,9 +413,9 @@
         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
 
@@ -495,10 +495,9 @@
                     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):
diff --git a/pypy/interpreter/pyframe.py b/pypy/interpreter/pyframe.py
--- a/pypy/interpreter/pyframe.py
+++ b/pypy/interpreter/pyframe.py
@@ -12,7 +12,7 @@
 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
@@ -622,8 +622,8 @@
 
         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:
@@ -639,8 +639,8 @@
                     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
@@ -687,9 +687,9 @@
         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
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -14,7 +14,7 @@
     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
@@ -492,8 +492,9 @@
 
     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):
@@ -848,9 +849,8 @@
             # 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()
@@ -899,8 +899,8 @@
     _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):
@@ -910,9 +910,9 @@
     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):
@@ -1040,9 +1040,8 @@
         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):
@@ -1127,9 +1126,9 @@
         w_enter = self.space.lookup(w_manager, "__enter__")
         w_descr = self.space.lookup(w_manager, "__exit__")
         if w_enter is None or w_descr is None:
-            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)
diff --git a/pypy/interpreter/test/test_error.py b/pypy/interpreter/test/test_error.py
--- a/pypy/interpreter/test/test_error.py
+++ b/pypy/interpreter/test/test_error.py
@@ -1,7 +1,7 @@
 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():
@@ -22,59 +22,59 @@
     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
 
diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py
--- a/pypy/interpreter/typedef.py
+++ b/pypy/interpreter/typedef.py
@@ -2,7 +2,7 @@
 
 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)
 
@@ -549,9 +549,9 @@
 
     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
@@ -620,8 +620,9 @@
 def descr_get_dict(space, w_obj):
     w_dict = w_obj.getdict(space)
     if w_dict is None:
-        msg = "descriptor '__dict__' doesn't apply to '%T' objects"
-        raise operationerrfmt(space.w_TypeError, msg, w_obj)
+        raise oefmt(space.w_TypeError,
+                    "descriptor '__dict__' doesn't apply to '%T' objects",
+                    w_obj)
     return w_dict
 
 def descr_set_dict(space, w_obj, w_dict):
diff --git a/pypy/module/__builtin__/interp_classobj.py b/pypy/module/__builtin__/interp_classobj.py
--- a/pypy/module/__builtin__/interp_classobj.py
+++ b/pypy/module/__builtin__/interp_classobj.py
@@ -1,5 +1,5 @@
 import new
-from pypy.interpreter.error import OperationError, operationerrfmt
+from pypy.interpreter.error import OperationError, oefmt
 from pypy.interpreter.gateway import interp2app
 from pypy.interpreter.typedef import TypeDef, make_weakref_descr
 from pypy.interpreter.baseobjspace import W_Root
@@ -10,8 +10,8 @@
 
 
 def raise_type_err(space, argument, expected, w_obj):
-    raise operationerrfmt(space.w_TypeError, "argument %s must be %s, not %T",
-                          argument, expected, w_obj)
+    raise oefmt(space.w_TypeError,
+                "argument %s must be %s, not %T", argument, expected, w_obj)
 
 def unwrap_attr(space, w_attr):
     try:
@@ -126,10 +126,8 @@
                 return space.newtuple(self.bases_w)
         w_value = self.lookup(space, name)
         if w_value is None:
-            raise operationerrfmt(
-                space.w_AttributeError,
-                "class %s has no attribute '%s'",
-                self.name, name)
+            raise oefmt(space.w_AttributeError,
+                        "class %s has no attribute '%s'", self.name, name)
 
         w_descr_get = space.lookup(w_value, '__get__')
         if w_descr_get is None:
@@ -158,18 +156,15 @@
     def descr_delattr(self, space, w_attr):
         name = unwrap_attr(space, w_attr)
         if name in ("__dict__", "__name__", "__bases__"):
-            raise operationerrfmt(
-                space.w_TypeError,
-                "cannot delete attribute '%s'", name)
+            raise oefmt(space.w_TypeError,
+                        "cannot delete attribute '%s'", name)
         try:
             space.delitem(self.w_dict, w_attr)
         except OperationError, e:
             if not e.match(space, space.w_KeyError):
                 raise
-            raise operationerrfmt(
-                space.w_AttributeError,
-                "class %s has no attribute '%s'",
-                self.name, name)
+            raise oefmt(space.w_AttributeError,
+                        "class %s has no attribute '%s'", self.name, name)
 
     def descr_repr(self, space):
         mod = self.get_module_string(space)
@@ -362,10 +357,9 @@
                 raise
         # not found at all
         if exc:
-            raise operationerrfmt(
-                space.w_AttributeError,
-                "%s instance has no attribute '%s'",
-                self.w_class.name, name)
+            raise oefmt(space.w_AttributeError,
+                        "%s instance has no attribute '%s'",
+                        self.w_class.name, name)
         else:
             return None
 
@@ -416,10 +410,9 @@
             space.call_function(w_meth, w_name)
         else:
             if not self.deldictvalue(space, name):
-                raise operationerrfmt(
-                    space.w_AttributeError,
-                    "%s instance has no attribute '%s'",
-                    self.w_class.name, name)
+                raise oefmt(space.w_AttributeError,
+                            "%s instance has no attribute '%s'",
+                            self.w_class.name, name)
 
     def descr_repr(self, space):
         w_meth = self.getattr(space, '__repr__', False)
diff --git a/pypy/module/__pypy__/interp_dict.py b/pypy/module/__pypy__/interp_dict.py
--- a/pypy/module/__pypy__/interp_dict.py
+++ b/pypy/module/__pypy__/interp_dict.py
@@ -1,6 +1,6 @@
 
+from pypy.interpreter.error import OperationError, oefmt
 from pypy.interpreter.gateway import unwrap_spec
-from pypy.interpreter.error import operationerrfmt, OperationError
 from pypy.objspace.std.dictmultiobject import W_DictMultiObject
 
 @unwrap_spec(type=str)
@@ -30,8 +30,7 @@
     elif type == 'strdict':
         return space.newdict(strdict=True)
     else:


More information about the pypy-commit mailing list