[pypy-svn] r42090 - pypy/dist/pypy/interpreter

arigo at codespeak.net arigo at codespeak.net
Mon Apr 16 14:37:20 CEST 2007


Author: arigo
Date: Mon Apr 16 14:37:19 2007
New Revision: 42090

Modified:
   pypy/dist/pypy/interpreter/pyopcode.py
Log:
Workaround for IMPORT_NAME semantic changes in 2.5.


Modified: pypy/dist/pypy/interpreter/pyopcode.py
==============================================================================
--- pypy/dist/pypy/interpreter/pyopcode.py	(original)
+++ pypy/dist/pypy/interpreter/pyopcode.py	Mon Apr 16 14:37:19 2007
@@ -707,6 +707,21 @@
         w_modulename = f.getname_w(nameindex)
         modulename = f.space.str_w(w_modulename)
         w_fromlist = f.popvalue()
+
+        # CPython 2.5 adds an obscure extra flag consumed by this opcode
+        if f.pycode.magic >= 0xa0df294:
+            w_flag = f.popvalue()
+            try:
+                if space.int_w(w_flag) == -1:
+                    w_flag = None     # don't provide the extra flag if == -1
+            except OperationError, e:
+                # let SystemExit and KeyboardInterrupt go through
+                if e.async(space):
+                    raise
+                # ignore other exceptions
+        else:
+            w_flag = None
+
         w_import = f.get_builtin().getdictvalue_w(f.space, '__import__')
         if w_import is None:
             raise OperationError(space.w_ImportError,
@@ -714,8 +729,14 @@
         w_locals = f.w_locals
         if w_locals is None:            # CPython does this
             w_locals = space.w_None
-        w_obj = space.call_function(w_import, space.wrap(modulename),
-                                    f.w_globals, w_locals, w_fromlist)
+        w_modulename = space.wrap(modulename)
+        w_globals = f.w_globals
+        if w_flag is None:
+            w_obj = space.call_function(w_import, w_modulename, w_globals,
+                                        w_locals, w_fromlist)
+        else:
+            w_obj = space.call_function(w_import, w_modulename, w_globals,
+                                        w_locals, w_fromlist, w_flag)
         f.pushvalue(w_obj)
 
     def IMPORT_STAR(f, *ignored):



More information about the Pypy-commit mailing list