[pypy-svn] r68305 - in pypy/trunk/pypy/module/posix: . test

benjamin at codespeak.net benjamin at codespeak.net
Sun Oct 11 00:57:50 CEST 2009


Author: benjamin
Date: Sun Oct 11 00:57:49 2009
New Revision: 68305

Modified:
   pypy/trunk/pypy/module/posix/interp_posix.py
   pypy/trunk/pypy/module/posix/test/test_posix2.py
Log:
os.getpgid() can raise an OSError #468

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	Sun Oct 11 00:57:49 2009
@@ -737,7 +737,11 @@
 
     Call the system call getpgid().
     """
-    return space.wrap(os.getpgid(pid))
+    try:
+        pgid = os.getpgid(pid)
+    except OSError, e:
+        raise wrap_oserror(space, e)
+    return space.wrap(pgid)
 getpgid.unwrap_spec = [ObjSpace, int]
 
 def setpgid(space, pid, pgrp):

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	Sun Oct 11 00:57:49 2009
@@ -47,6 +47,8 @@
             cls.w_geteuid = space.wrap(os.geteuid())
         if hasattr(os, 'getgid'):
             cls.w_getgid = space.wrap(os.getgid())
+        if hasattr(os, 'getpgid'):
+            cls.w_getpgid = space.wrap(os.getpgid(os.getpid()))
         if hasattr(os, 'getsid'):
             cls.w_getsid0 = space.wrap(os.getsid(0))
         if hasattr(os, 'sysconf'):
@@ -364,6 +366,12 @@
             os = self.posix
             assert os.getgid() == self.getgid
 
+    if hasattr(os, 'getpgid'):
+        def test_os_getpgid(self):
+            os = self.posix
+            assert os.getpgid(os.getpid()) == self.getpgid
+            raises(OSError, os.getpgid, 1234567)
+
     if hasattr(os, 'setgid'):
         def test_os_setgid_error(self):
             os = self.posix



More information about the Pypy-commit mailing list