[pypy-svn] r35189 - in pypy/dist/pypy/module/posix: . test
fijal at codespeak.net
fijal at codespeak.net
Fri Dec 1 10:48:19 CET 2006
Author: fijal
Date: Fri Dec 1 10:48:17 2006
New Revision: 35189
Modified:
pypy/dist/pypy/module/posix/__init__.py
pypy/dist/pypy/module/posix/interp_posix.py
pypy/dist/pypy/module/posix/test/test_posix2.py
Log:
Added (module-level) os.execv
Modified: pypy/dist/pypy/module/posix/__init__.py
==============================================================================
--- pypy/dist/pypy/module/posix/__init__.py (original)
+++ pypy/dist/pypy/module/posix/__init__.py Fri Dec 1 10:48:17 2006
@@ -70,6 +70,8 @@
interpleveldefs['fork'] = 'interp_posix.fork'
if hasattr(os, 'waitpid'):
interpleveldefs['waitpid'] = 'interp_posix.waitpid'
+ if hasattr(os, 'execv'):
+ interpleveldefs['execv'] = 'interp_posix.execv'
#if hasattr(ctypes_posix, 'uname'):
# interpleveldefs['uname'] = 'interp_posix.uname'
Modified: pypy/dist/pypy/module/posix/interp_posix.py
==============================================================================
--- pypy/dist/pypy/module/posix/interp_posix.py (original)
+++ pypy/dist/pypy/module/posix/interp_posix.py Fri Dec 1 10:48:17 2006
@@ -1,4 +1,4 @@
-from pypy.interpreter.baseobjspace import ObjSpace
+from pypy.interpreter.baseobjspace import ObjSpace, W_Root
from pypy.rlib.rarithmetic import intmask
from pypy.rlib import ros
from pypy.interpreter.error import OperationError
@@ -398,6 +398,10 @@
return space.wrap(intmask(_c.geteuid()))
geteuid.unwrap_spec = [ObjSpace]
+def execv(space, command, w_args):
+ os.execv(command, [space.str_w(i) for i in space.unpackiterable(w_args)])
+execv.unwrap_spec = [ObjSpace, str, W_Root]
+
def uname(space):
try:
result = _c.uname()
Modified: pypy/dist/pypy/module/posix/test/test_posix2.py
==============================================================================
--- pypy/dist/pypy/module/posix/test/test_posix2.py (original)
+++ pypy/dist/pypy/module/posix/test/test_posix2.py Fri Dec 1 10:48:17 2006
@@ -101,6 +101,16 @@
assert pid1 == pid
# XXX check status1
+ if hasattr(__import__(os.name), "execv"): # and fork
+ def test_execv(self):
+ os = self.posix
+ pid = os.fork()
+ if pid == 0:
+ os.execv("/usr/bin/env", ["env", "python", "-c", "open('onefile', 'w').write('1')"])
+ os.waitpid(pid, 0)
+ assert open("onefile").read() == "1"
+ os.unlink("onefile")
+
class AppTestEnvironment(object):
def setup_class(cls):
cls.space = space
More information about the Pypy-commit
mailing list