[pypy-svn] r79992 - in pypy/branch/more-posix/pypy/module/posix: . test

arigo at codespeak.net arigo at codespeak.net
Sat Dec 11 17:59:04 CET 2010


Author: arigo
Date: Sat Dec 11 17:59:03 2010
New Revision: 79992

Modified:
   pypy/branch/more-posix/pypy/module/posix/__init__.py
   pypy/branch/more-posix/pypy/module/posix/interp_posix.py
   pypy/branch/more-posix/pypy/module/posix/test/test_posix2.py
Log:
os.lchown().


Modified: pypy/branch/more-posix/pypy/module/posix/__init__.py
==============================================================================
--- pypy/branch/more-posix/pypy/module/posix/__init__.py	(original)
+++ pypy/branch/more-posix/pypy/module/posix/__init__.py	Sat Dec 11 17:59:03 2010
@@ -71,6 +71,8 @@
 
     if hasattr(os, 'chown'):
         interpleveldefs['chown'] = 'interp_posix.chown'
+    if hasattr(os, 'lchown'):
+        interpleveldefs['lchown'] = 'interp_posix.lchown'
     if hasattr(os, 'ftruncate'):
         interpleveldefs['ftruncate'] = 'interp_posix.ftruncate'
     if hasattr(os, 'fsync'):

Modified: pypy/branch/more-posix/pypy/module/posix/interp_posix.py
==============================================================================
--- pypy/branch/more-posix/pypy/module/posix/interp_posix.py	(original)
+++ pypy/branch/more-posix/pypy/module/posix/interp_posix.py	Sat Dec 11 17:59:03 2010
@@ -1000,6 +1000,14 @@
     return space.w_None
 chown.unwrap_spec = [ObjSpace, str, "c_nonnegint", "c_nonnegint"]
 
+def lchown(space, path, uid, gid):
+    try:
+        os.lchown(path, uid, gid)
+    except OSError, e:
+        raise wrap_oserror(space, e, path)
+    return space.w_None
+lchown.unwrap_spec = [ObjSpace, str, "c_nonnegint", "c_nonnegint"]
+
 def getloadavg(space):
     try:
         load = os.getloadavg()

Modified: pypy/branch/more-posix/pypy/module/posix/test/test_posix2.py
==============================================================================
--- pypy/branch/more-posix/pypy/module/posix/test/test_posix2.py	(original)
+++ pypy/branch/more-posix/pypy/module/posix/test/test_posix2.py	Sat Dec 11 17:59:03 2010
@@ -659,6 +659,14 @@
             f.close()
             os.chown(self.path, os.getuid(), os.getgid())
 
+    if hasattr(os, 'lchown'):
+        def test_lchown(self):
+            os = self.posix
+            os.unlink(self.path)
+            raises(OSError, os.lchown, self.path, os.getuid(), os.getgid())
+            os.symlink('foobar', self.path)
+            os.lchown(self.path, os.getuid(), os.getgid())
+
     if hasattr(os, 'mkfifo'):
         def test_mkfifo(self):
             os = self.posix



More information about the Pypy-commit mailing list