[pypy-svn] r31418 - in pypy/dist/pypy/module/posix: . test
rhymes at codespeak.net
rhymes at codespeak.net
Sun Aug 20 19:43:50 CEST 2006
Author: rhymes
Date: Sun Aug 20 19:43:46 2006
New Revision: 31418
Modified:
pypy/dist/pypy/module/posix/__init__.py
pypy/dist/pypy/module/posix/interp_posix.py
pypy/dist/pypy/module/posix/test/test_posix2.py
Log:
chown and chroot
Modified: pypy/dist/pypy/module/posix/__init__.py
==============================================================================
--- pypy/dist/pypy/module/posix/__init__.py (original)
+++ pypy/dist/pypy/module/posix/__init__.py Sun Aug 20 19:43:46 2006
@@ -65,6 +65,10 @@
interpleveldefs['fork'] = 'interp_posix.fork'
if hasattr(os, 'waitpid'):
interpleveldefs['waitpid'] = 'interp_posix.waitpid'
+ if hasattr(os, 'chown'):
+ interpleveldefs['chown'] = 'interp_posix.chown'
+ if hasattr(os, 'chroot'):
+ interpleveldefs['chroot'] = 'interp_posix.chroot'
for constant in dir(os):
Modified: pypy/dist/pypy/module/posix/interp_posix.py
==============================================================================
--- pypy/dist/pypy/module/posix/interp_posix.py (original)
+++ pypy/dist/pypy/module/posix/interp_posix.py Sun Aug 20 19:43:46 2006
@@ -411,3 +411,19 @@
return space.wrap(res)
access.unwrap_spec = [ObjSpace, str, int]
access.__doc__ = os.access.__doc__
+
+def chown(space, path, uid, gid):
+ try:
+ os.chown(path, uid, gid)
+ except OSError, e:
+ raise wrap_oserror(space, e)
+chown.unwrap_spec = [ObjSpace, str, int, int]
+chown.__doc__ = os.chown.__doc__
+
+def chroot(space, path):
+ try:
+ os.chroot(path)
+ except OSError, e:
+ raise wrap_oserror(space, e)
+chroot.unwrap_spec = [ObjSpace, str]
+chroot.__doc__ = os.chroot.__doc__
Modified: pypy/dist/pypy/module/posix/test/test_posix2.py
==============================================================================
--- pypy/dist/pypy/module/posix/test/test_posix2.py (original)
+++ pypy/dist/pypy/module/posix/test/test_posix2.py Sun Aug 20 19:43:46 2006
@@ -80,7 +80,9 @@
ex(self.posix.chdir, str(UNUSEDFD))
ex(self.posix.rmdir, str(UNUSEDFD))
ex(self.posix.listdir, str(UNUSEDFD))
- ex(self.posix.chmod, str(UNUSEDFD), 0777)
+ ex(self.posix.chmod, str(UNUSEDFD), 0777)
+ ex(self.posix.chown, str(UNUSEDFD), -1, -1)
+ ex(self.posix.chroot, str(UNUSEDFD))
def test_fdopen(self):
path = self.path
@@ -211,6 +213,18 @@
def test_access(self):
posix = self.posix
assert posix.access('.', posix.W_OK)
+
+ def test_chown(self):
+ posix = self.posix
+ path = self.path
+ stat_info = posix.stat(path)
+ uid, gid = stat_info.st_uid, stat_info.st_gid
+ posix.chown(path, -1, -1)
+ stat_info = posix.stat(path)
+ assert uid == stat_info.st_uid
+ assert gid == stat_info.st_gid
+ raises(OSError, posix.chown, path, 1000, 1000)
+
class AppTestEnvironment(object):
def setup_class(cls):
More information about the Pypy-commit
mailing list