[pypy-svn] r64532 - in pypy/trunk/pypy: module/posix module/posix/test rpython/module rpython/module/test
fijal at codespeak.net
fijal at codespeak.net
Tue Apr 21 17:57:16 CEST 2009
Author: fijal
Date: Tue Apr 21 17:57:16 2009
New Revision: 64532
Modified:
pypy/trunk/pypy/module/posix/__init__.py
pypy/trunk/pypy/module/posix/interp_posix.py
pypy/trunk/pypy/module/posix/test/test_posix2.py
pypy/trunk/pypy/rpython/module/ll_os.py
pypy/trunk/pypy/rpython/module/test/test_posix.py
Log:
os.chown
Modified: pypy/trunk/pypy/module/posix/__init__.py
==============================================================================
--- pypy/trunk/pypy/module/posix/__init__.py (original)
+++ pypy/trunk/pypy/module/posix/__init__.py Tue Apr 21 17:57:16 2009
@@ -55,6 +55,7 @@
'strerror' : 'interp_posix.strerror',
'pipe' : 'interp_posix.pipe',
'chmod' : 'interp_posix.chmod',
+ 'chown' : 'interp_posix.chown',
'rename' : 'interp_posix.rename',
'umask' : 'interp_posix.umask',
'_exit' : 'interp_posix._exit',
Modified: pypy/trunk/pypy/module/posix/interp_posix.py
==============================================================================
--- pypy/trunk/pypy/module/posix/interp_posix.py (original)
+++ pypy/trunk/pypy/module/posix/interp_posix.py Tue Apr 21 17:57:16 2009
@@ -809,3 +809,11 @@
num = space.int_w(w_num_or_name)
return space.wrap(os.sysconf(num))
sysconf.unwrap_spec = [ObjSpace, W_Root]
+
+def chown(space, path, uid, gid):
+ try:
+ os.chown(path, uid, gid)
+ except OSError, e:
+ raise wrap_oserror(space, e)
+ return space.w_None
+chown.unwrap_spec = [ObjSpace, str, int, int]
Modified: pypy/trunk/pypy/module/posix/test/test_posix2.py
==============================================================================
--- pypy/trunk/pypy/module/posix/test/test_posix2.py (original)
+++ pypy/trunk/pypy/module/posix/test/test_posix2.py Tue Apr 21 17:57:16 2009
@@ -435,6 +435,15 @@
for fd in range(start, stop):
raises(OSError, os.fstat, fd) # should have been closed
+ if hasattr(os, 'chown'):
+ def test_chown(self):
+ os = self.posix
+ os.unlink(self.path)
+ raises(OSError, os.chown, self.path, os.getuid(), os.getgid())
+ f = open(self.path, "w")
+ f.write("this is a test")
+ f.close()
+ os.chown(self.path, os.getuid(), os.getgid())
class AppTestEnvironment(object):
def setup_class(cls):
Modified: pypy/trunk/pypy/rpython/module/ll_os.py
==============================================================================
--- pypy/trunk/pypy/rpython/module/ll_os.py (original)
+++ pypy/trunk/pypy/rpython/module/ll_os.py Tue Apr 21 17:57:16 2009
@@ -1104,6 +1104,19 @@
"ll_os.ll_os_pipe",
llimpl=os_pipe_llimpl)
+ @registering_if(os, 'chown')
+ def register_os_chown(self):
+ os_chown = self.llexternal('chown', [rffi.CCHARP, rffi.INT, rffi.INT],
+ rffi.INT)
+
+ def os_chown_llimpl(path, uid, gid):
+ res = os_chown(path, uid, gid)
+ if res == -1:
+ raise OSError(rposix.get_errno(), "os_chown failed")
+
+ return extdef([str, int, int], None, "ll_os.ll_os_chown",
+ llimpl=os_chown_llimpl)
+
@registering_if(os, 'readlink')
def register_os_readlink(self):
os_readlink = self.llexternal('readlink',
Modified: pypy/trunk/pypy/rpython/module/test/test_posix.py
==============================================================================
--- pypy/trunk/pypy/rpython/module/test/test_posix.py (original)
+++ pypy/trunk/pypy/rpython/module/test/test_posix.py Tue Apr 21 17:57:16 2009
@@ -96,6 +96,22 @@
res = self.interpret(f,[fi,20])
assert self.ll_to_string(res) == text
+ if hasattr(os, 'chown'):
+ def test_chown(self):
+ f = open(path, "w")
+ f.write("xyz")
+ f.close()
+ def f():
+ try:
+ posix.chown(path, os.getuid(), os.getgid())
+ return 1
+ except OSError:
+ return 2
+
+ assert self.interpret(f, []) == 1
+ os.unlink(path)
+ assert self.interpret(f, []) == 2
+
def test_close(self):
def f(fi):
return posix.close(fi)
@@ -171,3 +187,6 @@
def test_os_chroot(self):
py.test.skip("ootypesystem does not support os.chroot")
+
+ def test_chown(self):
+ py.test.skip("ootypesystem does not support os.chown")
More information about the Pypy-commit
mailing list