[pypy-svn] r15425 - in pypy/dist/pypy: rpython rpython/module rpython/module/test translator/c translator/c/src translator/c/test

pedronis at codespeak.net pedronis at codespeak.net
Sat Jul 30 19:45:54 CEST 2005


Author: pedronis
Date: Sat Jul 30 19:45:42 2005
New Revision: 15425

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
   pypy/dist/pypy/translator/c/extfunc.py
   pypy/dist/pypy/translator/c/src/ll_os.h
   pypy/dist/pypy/translator/c/test/test_extfunc.py
Log:
strerror support



Modified: pypy/dist/pypy/rpython/extfunctable.py
==============================================================================
--- pypy/dist/pypy/rpython/extfunctable.py	(original)
+++ pypy/dist/pypy/rpython/extfunctable.py	Sat Jul 30 19:45:42 2005
@@ -78,6 +78,7 @@
 declare(os.ftruncate, noneannotation, 'll_os/ftruncate')
 declare(os.fstat    , statannotation, 'll_os/fstat')
 declare(os.stat     , statannotation, 'll_os/stat')
+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')
 declare(time.time   , float         , 'll_time/time')

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	Sat Jul 30 19:45:42 2005
@@ -109,3 +109,7 @@
     return ll_stat_result(stat0, stat1, stat2, stat3, stat4,
                           stat5, stat6, stat7, stat8, stat9)
 ll_os_stat.suggested_primitive = True
+
+def ll_os_strerror(errnum):
+    return to_rstr(os.strerror(errnum))
+ll_os_getcwd.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	Sat Jul 30 19:45:42 2005
@@ -23,3 +23,7 @@
 def test_getcwd():
     data = ll_os_getcwd()
     assert from_rstr(data) == os.getcwd()
+
+def test_strerror():
+    data = ll_os_strerror(2)
+    assert from_rstr(data) == os.strerror(2)

Modified: pypy/dist/pypy/translator/c/extfunc.py
==============================================================================
--- pypy/dist/pypy/translator/c/extfunc.py	(original)
+++ pypy/dist/pypy/translator/c/extfunc.py	Sat Jul 30 19:45:42 2005
@@ -19,6 +19,7 @@
     ll_os  .ll_os_lseek:   'LL_os_lseek',
     ll_os  .ll_os_isatty:  'LL_os_isatty',
     ll_os  .ll_os_ftruncate:'LL_os_ftruncate',
+    ll_os  .ll_os_strerror: 'LL_os_strerror',
     ll_time.ll_time_clock: 'LL_time_clock',
     ll_time.ll_time_sleep: 'LL_time_sleep',
     ll_time.ll_time_time:  'LL_time_time',

Modified: pypy/dist/pypy/translator/c/src/ll_os.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/ll_os.h	(original)
+++ pypy/dist/pypy/translator/c/src/ll_os.h	Sat Jul 30 19:45:42 2005
@@ -167,3 +167,10 @@
 	RAISE_OSERROR(errno);
     }
 }
+
+RPyString *LL_os_strerror(int errnum)
+{
+	char *res;
+	res = strerror(errnum);
+	return RPyString_FromString(res);
+}

Modified: pypy/dist/pypy/translator/c/test/test_extfunc.py
==============================================================================
--- pypy/dist/pypy/translator/c/test/test_extfunc.py	(original)
+++ pypy/dist/pypy/translator/c/test/test_extfunc.py	Sat Jul 30 19:45:42 2005
@@ -134,6 +134,13 @@
     res = f1()
     assert res == os.getcwd()
 
+def test_strerror():
+    def does_stuff():
+        return os.strerror(2)
+    f1 = compile(does_stuff, [])
+    res = f1()
+    assert res == os.strerror(2)
+
 def test_math_frexp():
     from math import frexp
     def fn(x):



More information about the Pypy-commit mailing list