[pypy-svn] r45723 - in pypy/branch/pypy-more-rtti-inprogress: rpython rpython/module translator/c translator/c/src translator/c/test
arigo at codespeak.net
arigo at codespeak.net
Thu Aug 16 16:04:44 CEST 2007
Author: arigo
Date: Thu Aug 16 16:04:43 2007
New Revision: 45723
Modified:
pypy/branch/pypy-more-rtti-inprogress/rpython/extfunctable.py
pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py
pypy/branch/pypy-more-rtti-inprogress/translator/c/extfunc.py
pypy/branch/pypy-more-rtti-inprogress/translator/c/src/ll_os.h
pypy/branch/pypy-more-rtti-inprogress/translator/c/test/test_extfunc.py
Log:
os.system()...
Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/extfunctable.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/rpython/extfunctable.py (original)
+++ pypy/branch/pypy-more-rtti-inprogress/rpython/extfunctable.py Thu Aug 16 16:04:43 2007
@@ -150,7 +150,6 @@
# external function declarations
posix = __import__(os.name)
-declare(os.system , int , 'll_os/system')
declare(os.unlink , noneannotation, 'll_os/unlink')
declare(os.chdir , noneannotation, 'll_os/chdir')
declare(os.mkdir , noneannotation, 'll_os/mkdir')
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 Thu Aug 16 16:04:43 2007
@@ -629,6 +629,19 @@
self.register(os.strerror, [int], str, llimpl=strerror_lltypeimpl,
export_name="ll_os.ll_os_strerror")
+ @registering(os.system)
+ def register_os_system(self):
+ os_system = rffi.llexternal('system', [rffi.CCHARP], rffi.INT)
+
+ def system_lltypeimpl(command):
+ l_command = rffi.str2charp(command)
+ res = os_system(l_command)
+ rffi.free_charp(l_command)
+ return res
+
+ self.register(os.system, [str], int, llimpl=system_lltypeimpl,
+ export_name="ll_os.ll_os_system")
+
# --------------------------- os.stat & variants ---------------------------
@registering(os.fstat)
@@ -718,10 +731,6 @@
# XXX deprecated style, this is all waiting to be converted to rffi
__metaclass__ = ClassMethods
- def ll_os_system(cls, cmd):
- return os.system(cls.from_rstr(cmd))
- ll_os_system.suggested_primitive = True
-
def ll_os_unlink(cls, path):
os.unlink(cls.from_rstr(path))
ll_os_unlink.suggested_primitive = True
Modified: pypy/branch/pypy-more-rtti-inprogress/translator/c/extfunc.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/translator/c/extfunc.py (original)
+++ pypy/branch/pypy-more-rtti-inprogress/translator/c/extfunc.py Thu Aug 16 16:04:43 2007
@@ -20,7 +20,6 @@
# references to functions, so we cannot insert classmethods here.
EXTERNALS = {
- impl.ll_os_system.im_func: 'LL_os_system',
impl.ll_os_unlink.im_func: 'LL_os_unlink',
impl.ll_os_chdir.im_func: 'LL_os_chdir',
impl.ll_os_mkdir.im_func: 'LL_os_mkdir',
Modified: pypy/branch/pypy-more-rtti-inprogress/translator/c/src/ll_os.h
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/translator/c/src/ll_os.h (original)
+++ pypy/branch/pypy-more-rtti-inprogress/translator/c/src/ll_os.h Thu Aug 16 16:04:43 2007
@@ -68,10 +68,6 @@
#include "ll_osdefs.h"
-long LL_os_system(RPyString * fname) {
- return system(RPyString_AsString(fname));
-}
-
void LL_os_unlink(RPyString * fname) {
int error = unlink(RPyString_AsString(fname));
if (error != 0) {
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 Thu Aug 16 16:04:43 2007
@@ -225,6 +225,13 @@
res = f1()
assert res == os.strerror(2)
+def test_system():
+ def does_stuff(cmd):
+ return os.system(cmd)
+ f1 = compile(does_stuff, [str])
+ res = f1("echo hello")
+ assert res == 0
+
def test_math_pow():
import math
def fn(x, y):
More information about the Pypy-commit
mailing list