[pypy-commit] pypy py3k: move W_OperationError to avoid a circular import

pjenvey noreply at buildbot.pypy.org
Wed Mar 14 03:11:25 CET 2012


Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r53523:d9764af9381c
Date: 2012-03-13 19:10 -0700
http://bitbucket.org/pypy/pypy/changeset/d9764af9381c/

Log:	move W_OperationError to avoid a circular import

diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py
--- a/pypy/interpreter/error.py
+++ b/pypy/interpreter/error.py
@@ -471,14 +471,3 @@
 def typed_unwrap_error_msg(space, expected, w_obj):
     type_name = space.type(w_obj).getname(space)
     return space.wrap("expected %s, got %s object" % (expected, type_name))
-
-
-from pypy.interpreter.baseobjspace import Wrappable
-
-class W_OperationError(Wrappable):
-    """
-    Tiny applevel wrapper around an OperationError.
-    """
-
-    def __init__(self, operr):
-        self.operr = operr
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -528,7 +528,6 @@
             self.setdictscope(w_locals)
 
     def POP_EXCEPT(self, oparg, next_instr):
-        from pypy.interpreter.error import W_OperationError
         assert self.space.py3k
         # on CPython, POP_EXCEPT also pops the block. Here, the block is
         # automatically popped by unrollstack()
@@ -1295,7 +1294,6 @@
         # instead of the traceback, we store the unroller object,
         # wrapped.
         if frame.space.py3k:
-            from pypy.interpreter.error import W_OperationError
             # this is popped by POP_EXCEPT, which is present only in py3k
             w_last_exception = W_OperationError(frame.last_exception)
             w_last_exception = frame.space.wrap(w_last_exception)
@@ -1363,6 +1361,16 @@
                  'SETUP_WITH': WithBlock,
                  }
 
+
+class W_OperationError(Wrappable):
+    """
+    Tiny applevel wrapper around an OperationError.
+    """
+
+    def __init__(self, operr):
+        self.operr = operr
+
+
 ### helpers written at the application-level ###
 # Some of these functions are expected to be generally useful if other
 # parts of the code need to do the same thing as a non-trivial opcode,
diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py
--- a/pypy/interpreter/typedef.py
+++ b/pypy/interpreter/typedef.py
@@ -6,7 +6,7 @@
 from pypy.interpreter.gateway import interp2app, BuiltinCode
 from pypy.interpreter.argument import Arguments
 from pypy.interpreter.baseobjspace import Wrappable, DescrMismatch
-from pypy.interpreter.error import OperationError, operationerrfmt, W_OperationError
+from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.tool.sourcetools import compile2, func_with_new_name
 from pypy.rlib.objectmodel import instantiate, compute_identity_hash, specialize
 from pypy.rlib.jit import promote
@@ -614,7 +614,7 @@
 from pypy.interpreter.eval import Code, Frame
 from pypy.interpreter.pycode import PyCode, CO_VARARGS, CO_VARKEYWORDS
 from pypy.interpreter.pyframe import PyFrame
-from pypy.interpreter.pyopcode import SuspendedUnroller
+from pypy.interpreter.pyopcode import SuspendedUnroller, W_OperationError
 from pypy.interpreter.module import Module
 from pypy.interpreter.function import Function, Method, StaticMethod
 from pypy.interpreter.function import ClassMethod


More information about the pypy-commit mailing list