[pypy-svn] r16221 - in pypy/dist/pypy/rpython: . module module/test
tismer at codespeak.net
tismer at codespeak.net
Mon Aug 22 18:46:44 CEST 2005
Author: tismer
Date: Mon Aug 22 18:46:42 2005
New Revision: 16221
Modified:
pypy/dist/pypy/rpython/extfunctable.py
pypy/dist/pypy/rpython/module/ll_os.py
pypy/dist/pypy/rpython/module/test/test_ll_os.py
Log:
support for os.system
this is rather simple to implement, and needed
in order to fake the compiler from the executable.
Modified: pypy/dist/pypy/rpython/extfunctable.py
==============================================================================
--- pypy/dist/pypy/rpython/extfunctable.py (original)
+++ pypy/dist/pypy/rpython/extfunctable.py Mon Aug 22 18:46:42 2005
@@ -141,6 +141,7 @@
declare(os.ftruncate, noneannotation, 'll_os/ftruncate')
declare(os.fstat , statannotation, 'll_os/fstat')
declare(os.stat , statannotation, 'll_os/stat')
+declare(os.system , int , 'll_os/system')
declare(os.strerror , str , 'll_os/strerror')
declare(os.path.exists, bool , 'll_os_path/exists')
declare(os.path.isdir, bool , 'll_os_path/isdir')
Modified: pypy/dist/pypy/rpython/module/ll_os.py
==============================================================================
--- pypy/dist/pypy/rpython/module/ll_os.py (original)
+++ pypy/dist/pypy/rpython/module/ll_os.py Mon Aug 22 18:46:42 2005
@@ -113,3 +113,7 @@
def ll_os_strerror(errnum):
return to_rstr(os.strerror(errnum))
ll_os_getcwd.suggested_primitive = True
+
+def ll_os_system(cmd):
+ return os.system(from_rstr(cmd))
+ll_os_system.suggested_primitive = True
Modified: pypy/dist/pypy/rpython/module/test/test_ll_os.py
==============================================================================
--- pypy/dist/pypy/rpython/module/test/test_ll_os.py (original)
+++ pypy/dist/pypy/rpython/module/test/test_ll_os.py Mon Aug 22 18:46:42 2005
@@ -27,3 +27,10 @@
def test_strerror():
data = ll_os_strerror(2)
assert from_rstr(data) == os.strerror(2)
+
+def test_system():
+ arg = to_rstr('python -c "print 1+1" > x')
+ data = ll_os_system(arg)
+ assert data == 0
+ assert file('x').read().strip() == '2'
+ os.unlink('x')
More information about the Pypy-commit
mailing list