[pypy-svn] r45722 - in pypy/branch/pypy-more-rtti-inprogress: rpython rpython/module translator/c translator/c/src
arigo at codespeak.net
arigo at codespeak.net
Thu Aug 16 15:59:07 CEST 2007
Author: arigo
Date: Thu Aug 16 15:59:07 2007
New Revision: 45722
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
Log:
os.strerror()...
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 15:59:07 2007
@@ -151,7 +151,6 @@
# external function declarations
posix = __import__(os.name)
declare(os.system , int , 'll_os/system')
-declare(os.strerror , str , 'll_os/strerror')
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 15:59:07 2007
@@ -616,6 +616,19 @@
self.register(os.isatty, [int], bool, llimpl=isatty_lltypeimpl,
export_name="ll_os.ll_os_isatty")
+ @registering(os.strerror)
+ def register_os_strerror(self):
+ os_strerror = rffi.llexternal('strerror', [rffi.INT], rffi.CCHARP)
+
+ def strerror_lltypeimpl(errnum):
+ res = os_strerror(rffi.cast(rffi.INT, errnum))
+ if not res:
+ raise ValueError("os_strerror failed")
+ return rffi.charp2str(res)
+
+ self.register(os.strerror, [int], str, llimpl=strerror_lltypeimpl,
+ export_name="ll_os.ll_os_strerror")
+
# --------------------------- os.stat & variants ---------------------------
@registering(os.fstat)
@@ -705,10 +718,6 @@
# XXX deprecated style, this is all waiting to be converted to rffi
__metaclass__ = ClassMethods
- def ll_os_strerror(cls, errnum):
- return cls.to_rstr(os.strerror(errnum))
- ll_os_strerror.suggested_primitive = True
-
def ll_os_system(cls, cmd):
return os.system(cls.from_rstr(cmd))
ll_os_system.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 15:59:07 2007
@@ -20,7 +20,6 @@
# references to functions, so we cannot insert classmethods here.
EXTERNALS = {
- impl.ll_os_strerror.im_func: 'LL_os_strerror',
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',
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 15:59:07 2007
@@ -39,7 +39,6 @@
/* prototypes */
int LL_os_isatty(long fd);
-RPyString *LL_os_strerror(int errnum);
long LL_os_system(RPyString * fname);
void LL_os_unlink(RPyString * fname);
void LL_os_chdir(RPyString * path);
@@ -69,17 +68,6 @@
#include "ll_osdefs.h"
-RPyString *LL_os_strerror(int errnum) {
- char *res;
- res = strerror(errnum);
- if (res == NULL) {
- RPyRaiseSimpleException(PyExc_ValueError,
- "strerror() argument out of range");
- return NULL;
- }
- return RPyString_FromString(res);
-}
-
long LL_os_system(RPyString * fname) {
return system(RPyString_AsString(fname));
}
More information about the Pypy-commit
mailing list