[pypy-svn] commit/pypy: arigo: Test and fix.

Bitbucket commits-noreply at bitbucket.org
Sun Dec 19 15:31:37 CET 2010


1 new changeset in pypy:

http://bitbucket.org/pypy/pypy/changeset/3a56f62ba3e5/
changeset:   r40131:3a56f62ba3e5
user:        arigo
date:        2010-12-19 15:31:26
summary:     Test and fix.
affected #:  2 files (780 bytes)

--- a/pypy/interpreter/pyopcode.py	Sun Dec 19 14:45:54 2010 +0100
+++ b/pypy/interpreter/pyopcode.py	Sun Dec 19 15:31:26 2010 +0100
@@ -778,6 +778,12 @@
         # CPython 2.5 adds an extra argument consumed by this opcode
         if self.pycode.magic >= 0xa0df294:
             w_flag = self.popvalue()
+            try:
+                if space.int_w(w_flag) == -1:
+                    w_flag = None
+            except OperationError, e:
+                if e.async(space):
+                    raise
         else:
             w_flag = None
 


--- a/pypy/interpreter/test/test_interpreter.py	Sun Dec 19 14:45:54 2010 +0100
+++ b/pypy/interpreter/test/test_interpreter.py	Sun Dec 19 15:31:26 2010 +0100
@@ -156,6 +156,21 @@
             '''
         self.codetest(code, 'f', [])
 
+    def test_import_default_arg(self):
+        # CPython does not always call __import__() with 5 arguments,
+        # but only if the 5th one is not -1.
+        real_call_function = self.space.call_function
+        space = self.space
+        def safe_call_function(w_obj, *arg_w):
+            assert not arg_w or not space.eq_w(arg_w[-1], space.wrap(-1))
+            return real_call_function(w_obj, *arg_w)
+        self.space.call_function = safe_call_function
+        code = '''
+            def f():
+                import sys
+            '''
+        self.codetest(code, 'f', [])
+
     def test_call_star_starstar(self):
         code = '''\
             def f1(n):

Repository URL: https://bitbucket.org/pypy/pypy/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the Pypy-commit mailing list