Commits

Armin Rigo  committed e6a6bec

(iko, rguillebert, arigo)

CPython 2.7 semantics are too messy to follow exactly, e.g.
setuid(-2) works on 32-bit but not on 64-bit. The exact rules
are rather complicated, and of course the ones we implemented are
a bit different than CPython's. As a result, we decided to just
accept any 'int', i.e. any C signed long. This is basically
reverting back to the situation of CPython 2.5, I think.

  • Participants
  • Parent commits 9af9046

Comments (0)

Files changed (2)

File pypy/module/posix/interp_posix.py

 _WIN = sys.platform == 'win32'
 
 c_int = "c_int"
-c_nonnegint = "c_nonnegint"
+
+# CPython 2.7 semantics are too messy to follow exactly,
+# e.g. setuid(-2) works on 32-bit but not on 64-bit.  As a result,
+# we decided to just accept any 'int', i.e. any C signed long.
+c_uid_t = int
+c_gid_t = int
 
 class FileEncoder(object):
     def __init__(self, space, w_obj):
     """
     return space.wrap(os.getuid())
 
-@unwrap_spec(arg=c_nonnegint)
+@unwrap_spec(arg=int)
 def setuid(space, arg):
     """ setuid(uid)
 
         raise wrap_oserror(space, e)
     return space.w_None
 
-@unwrap_spec(arg=c_nonnegint)
+@unwrap_spec(arg=c_uid_t)
 def seteuid(space, arg):
     """ seteuid(uid)
 
         raise wrap_oserror(space, e)
     return space.w_None
 
-@unwrap_spec(arg=c_nonnegint)
+@unwrap_spec(arg=c_gid_t)
 def setgid(space, arg):
     """ setgid(gid)
 
         raise wrap_oserror(space, e)
     return space.w_None
 
-@unwrap_spec(arg=c_nonnegint)
+@unwrap_spec(arg=c_gid_t)
 def setegid(space, arg):
     """ setegid(gid)
 
         raise wrap_oserror(space, e)
     return space.w_None
 
-@unwrap_spec(ruid=c_int, euid=c_int)
+@unwrap_spec(ruid=c_uid_t, euid=c_uid_t)
 def setreuid(space, ruid, euid):
     """ setreuid(ruid, euid)
 
         raise wrap_oserror(space, e)
     return space.w_None
 
-@unwrap_spec(rgid=c_int, egid=c_int)
+@unwrap_spec(rgid=c_gid_t, egid=c_gid_t)
 def setregid(space, rgid, egid):
     """ setregid(rgid, egid)
 
     except OSError, e:
         raise wrap_oserror(space, e)
 
-@unwrap_spec(path=str, uid=c_int, gid=c_int)
+@unwrap_spec(path=str, uid=c_uid_t, gid=c_gid_t)
 def chown(space, path, uid, gid):
     try:
         os.chown(path, uid, gid)
         raise wrap_oserror(space, e, path)
     return space.w_None
 
-@unwrap_spec(path=str, uid=c_int, gid=c_int)
+@unwrap_spec(path=str, uid=c_uid_t, gid=c_gid_t)
 def lchown(space, path, uid, gid):
     try:
         os.lchown(path, uid, gid)

File pypy/module/posix/test/test_posix2.py

 
 # -*- coding: utf-8 -*-
 
+from __future__ import with_statement
 from pypy.objspace.std import StdObjSpace
 from pypy.tool.udir import udir
 from pypy.conftest import gettestobjspace
 
     if hasattr(os, 'setuid'):
         def test_os_setuid_error(self):
+            skip("overflow checking disabled for now")
             os = self.posix
             raises((OSError, ValueError, OverflowError), os.setuid, -100000)
 
 
     if hasattr(os, 'setgid'):
         def test_os_setgid_error(self):
+            skip("overflow checking disabled for now")
             os = self.posix
             raises((OSError, ValueError, OverflowError), os.setgid, -100000)
 
         def test_os_getsid(self):
             os = self.posix
             assert os.getsid(0) == self.getsid0
-            raises((OSError, ValueError, OverflowError), os.getsid, -100000)
+            raises(OSError, os.getsid, -100000)
 
     if hasattr(os, 'sysconf'):
         def test_os_sysconf(self):