[pypy-svn] r45726 - 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:17:58 CEST 2007
Author: arigo
Date: Thu Aug 16 16:17:57 2007
New Revision: 45726
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.chmod()...
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:17:57 2007
@@ -150,9 +150,6 @@
# external function declarations
posix = __import__(os.name)
-if hasattr(posix, 'unsetenv'): # note: faked in os
- declare(os.unsetenv , noneannotation, 'll_os/unsetenv')
-declare(os.chmod , noneannotation, 'll_os/chmod')
declare(os.rename , noneannotation, 'll_os/rename')
declare(os.umask , int , 'll_os/umask')
declare(os._exit , noneannotation, 'll_os/_exit')
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:17:57 2007
@@ -719,6 +719,27 @@
self.register(os.rmdir, [str], s_None, llimpl=rmdir_lltypeimpl,
export_name="ll_os.ll_os_rmdir")
+ @registering(os.chmod)
+ def register_os_chmod(self):
+ if os.name == 'nt':
+ INCLUDES = []
+ MODE_T = rffi.INT
+ else:
+ INCLUDES = ['sys/stat.h', 'sys/types.h']
+ MODE_T = rffi.MODE_T
+ os_chmod = rffi.llexternal('chmod', [rffi.CCHARP, MODE_T], rffi.INT,
+ includes=INCLUDES)
+
+ def chmod_lltypeimpl(path, mode):
+ l_path = rffi.str2charp(path)
+ res = os_chmod(l_path, rffi.cast(MODE_T, mode))
+ rffi.free_charp(l_path)
+ if res < 0:
+ raise OSError(rffi.get_errno(), "os_chmod failed")
+
+ self.register(os.chmod, [str, int], s_None, llimpl=chmod_lltypeimpl,
+ export_name="ll_os.ll_os_chmod")
+
# --------------------------- os.stat & variants ---------------------------
@registering(os.fstat)
@@ -808,10 +829,6 @@
# XXX deprecated style, this is all waiting to be converted to rffi
__metaclass__ = ClassMethods
- def ll_os_chmod(cls, path, mode):
- os.chmod(cls.from_rstr(path), mode)
- ll_os_chmod.suggested_primitive = True
-
def ll_os_rename(cls, path1, path2):
os.rename(cls.from_rstr(path1), cls.from_rstr(path2))
ll_os_rename.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:17:57 2007
@@ -20,7 +20,6 @@
# references to functions, so we cannot insert classmethods here.
EXTERNALS = {
- impl.ll_os_chmod.im_func: 'LL_os_chmod',
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',
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:17:57 2007
@@ -68,13 +68,6 @@
#include "ll_osdefs.h"
-void LL_os_chmod(RPyString * path, int mode) {
- int error = chmod(RPyString_AsString(path), mode);
- if (error != 0) {
- RPYTHON_RAISE_OSERROR(errno);
- }
-}
-
void LL_os_rename(RPyString * path1, RPyString * path2) {
int error = rename(RPyString_AsString(path1), RPyString_AsString(path2));
if (error != 0) {
More information about the Pypy-commit
mailing list