[pypy-svn] r45727 - 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 16:19:34 CEST 2007
Author: arigo
Date: Thu Aug 16 16:19:34 2007
New Revision: 45727
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.rename()...
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:19:34 2007
@@ -150,7 +150,6 @@
# external function declarations
posix = __import__(os.name)
-declare(os.rename , noneannotation, 'll_os/rename')
declare(os.umask , int , 'll_os/umask')
declare(os._exit , noneannotation, 'll_os/_exit')
if hasattr(os, 'kill'):
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:19:34 2007
@@ -740,6 +740,23 @@
self.register(os.chmod, [str, int], s_None, llimpl=chmod_lltypeimpl,
export_name="ll_os.ll_os_chmod")
+ @registering(os.rename)
+ def register_os_rename(self):
+ os_rename = rffi.llexternal('rename', [rffi.CCHARP, rffi.CCHARP],
+ rffi.INT)
+
+ def rename_lltypeimpl(oldpath, newpath):
+ l_oldpath = rffi.str2charp(oldpath)
+ l_newpath = rffi.str2charp(newpath)
+ res = os_rename(l_oldpath, l_newpath)
+ rffi.free_charp(l_newpath)
+ rffi.free_charp(l_oldpath)
+ if res < 0:
+ raise OSError(rffi.get_errno(), "os_rename failed")
+
+ self.register(os.rename, [str, str], s_None, llimpl=rename_lltypeimpl,
+ export_name="ll_os.ll_os_rename")
+
# --------------------------- os.stat & variants ---------------------------
@registering(os.fstat)
@@ -829,10 +846,6 @@
# XXX deprecated style, this is all waiting to be converted to rffi
__metaclass__ = ClassMethods
- def ll_os_rename(cls, path1, path2):
- os.rename(cls.from_rstr(path1), cls.from_rstr(path2))
- ll_os_rename.suggested_primitive = True
-
def ll_os_umask(cls, mask):
return os.umask(mask)
ll_os_umask.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:19:34 2007
@@ -20,7 +20,6 @@
# references to functions, so we cannot insert classmethods here.
EXTERNALS = {
- impl.ll_os_rename.im_func: 'LL_os_rename',
impl.ll_os_umask.im_func: 'LL_os_umask',
impl.ll_os_kill.im_func: 'LL_os_kill',
impl.ll_os_link.im_func: 'LL_os_link',
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:19:34 2007
@@ -68,13 +68,6 @@
#include "ll_osdefs.h"
-void LL_os_rename(RPyString * path1, RPyString * path2) {
- int error = rename(RPyString_AsString(path1), RPyString_AsString(path2));
- if (error != 0) {
- RPYTHON_RAISE_OSERROR(errno);
- }
-}
-
int LL_os_umask(int mode) {
return umask(mode);
}
More information about the pypy-svn
mailing list