[pypy-svn] r75698 - in pypy/branch/fast-forward/pypy/module/posix: . test

benjamin at codespeak.net benjamin at codespeak.net
Wed Jun 30 21:00:47 CEST 2010


Author: benjamin
Date: Wed Jun 30 21:00:44 2010
New Revision: 75698

Modified:
   pypy/branch/fast-forward/pypy/module/posix/interp_posix.py
   pypy/branch/fast-forward/pypy/module/posix/test/test_posix2.py
Log:
fix test

Modified: pypy/branch/fast-forward/pypy/module/posix/interp_posix.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/posix/interp_posix.py	(original)
+++ pypy/branch/fast-forward/pypy/module/posix/interp_posix.py	Wed Jun 30 21:00:44 2010
@@ -550,19 +550,21 @@
         path: path of executable file
         args: iterable of strings
     """
-    args_w = space.unpackiterable(w_args)
-    if len(args_w) < 1:
-        w_msg = space.wrap("execv() must have at least one argument")
-        raise OperationError(space.w_ValueError, w_msg)
     try:
-        os.execv(command, [space.str_w(w_arg) for w_arg in args_w])
+        args_w = space.unpackiterable(w_args)
+        if len(args_w) < 1:
+            w_msg = space.wrap("execv() must have at least one argument")
+            raise OperationError(space.w_ValueError, w_msg)
+        args = [space.str_w(w_arg) for w_arg in args_w]
     except OperationError, e:
         if not e.match(space, space.w_TypeError):
             raise
         msg = "execv() arg 2 must be an iterable of strings"
         raise OperationError(space.w_TypeError, space.wrap(str(msg)))
+    try:
+        os.execv(command, args)
     except OSError, e:
-        raise wrap_oserror(space, e) 
+        raise wrap_oserror(space, e)
 execv.unwrap_spec = [ObjSpace, str, W_Root]
 
 def execve(space, command, w_args, w_env):

Modified: pypy/branch/fast-forward/pypy/module/posix/test/test_posix2.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/posix/test/test_posix2.py	(original)
+++ pypy/branch/fast-forward/pypy/module/posix/test/test_posix2.py	Wed Jun 30 21:00:44 2010
@@ -355,15 +355,13 @@
 
         def test_execv_raising2(self):
             os = self.posix
-            def t(n):
+            for n in 3, [3, "a"]:
                 try:
                     os.execv("xxx", n)
                 except TypeError,t:
-                    assert t.args[0] == "execv() arg 2 must be an iterable of strings"
+                    assert str(t) == "execv() arg 2 must be an iterable of strings"
                 else:
                     py.test.fail("didn't raise")
-            t(3)
-            t([3, "a"])
 
         def test_execve(self):
             os = self.posix



More information about the Pypy-commit mailing list