[pypy-svn] r46274 - in pypy/branch/pypy-more-rtti-inprogress: rpython/module translator/c/test

arigo at codespeak.net arigo at codespeak.net
Mon Sep 3 14:27:47 CEST 2007


Author: arigo
Date: Mon Sep  3 14:27:46 2007
New Revision: 46274

Modified:
   pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py
   pypy/branch/pypy-more-rtti-inprogress/translator/c/test/test_extfunc.py
Log:
More progress, mostly test fixing.


Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py	(original)
+++ pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py	Mon Sep  3 14:27:46 2007
@@ -96,7 +96,7 @@
         def spawnv_llimpl(mode, path, args):
             mode = rffi.cast(rffi.INT, mode)
             l_args = rffi.liststr2charpp(args)
-            childpid = os_spawnv(mode, l_path, l_args)
+            childpid = os_spawnv(mode, path, l_args)
             rffi.free_charpp(l_args)
             if childpid == -1:
                 raise OSError(rffi.get_errno(), "os_spawnv failed")

Modified: pypy/branch/pypy-more-rtti-inprogress/translator/c/test/test_extfunc.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/translator/c/test/test_extfunc.py	(original)
+++ pypy/branch/pypy-more-rtti-inprogress/translator/c/test/test_extfunc.py	Mon Sep  3 14:27:46 2007
@@ -599,7 +599,7 @@
         return mask2
     f1 = compile(does_stuff, [])
     res = f1()
-    assert res == 0660
+    assert res == does_stuff()
 
 if hasattr(os, 'getpid'):
     def test_os_getpid():
@@ -834,12 +834,12 @@
         compared_with.sort()
         assert result == compared_with
 
-if hasattr(posix, 'execv'):
+if hasattr(posix, 'execv') and hasattr(posix, 'fork'):
     def test_execv():
         filename = str(udir.join('test_execv.txt'))
         def does_stuff():
             progname = str(sys.executable)
-            l = [progname, '-c', 'open("%s","w").write("1")' % filename]
+            l = [progname, '-c', 'open(%r,"w").write("1")' % filename]
             pid = os.fork()
             if pid == 0:
                 os.execv(progname, l)
@@ -866,7 +866,7 @@
             l = []
             l.append(progname)
             l.append("-c")
-            l.append('import os; open("%s", "w").write(os.environ["STH"])' % filename)
+            l.append('import os; open(%r, "w").write(os.environ["STH"])' % filename)
             env = {}
             env["STH"] = "42"
             env["sthelse"] = "a"
@@ -884,8 +884,17 @@
     def test_spawnv():
         filename = str(udir.join('test_spawnv.txt'))
         progname = str(sys.executable)
+        scriptpath = udir.join('test_spawnv.py')
+        scriptpath.write('f=open(%r,"w")\nf.write("2")\nf.close\n' % filename)
+        scriptname = str(scriptpath)
         def does_stuff():
-            l = [progname, '-c', 'open("%s","w").write("2")' % filename]
+            # argument quoting on Windows is completely ill-defined.
+            # don't let yourself be fooled by the idea that if os.spawnv()
+            # takes a list of strings, then the receiving program will
+            # nicely see these strings as arguments with no further quote
+            # processing.  Achieving this is nearly impossible - even
+            # CPython doesn't try at all.
+            l = [progname, scriptname]
             pid = os.spawnv(os.P_NOWAIT, progname, l)
             os.waitpid(pid, 0)
         func = compile(does_stuff, [])



More information about the Pypy-commit mailing list