[pypy-svn] pypy default: Handle failure cases, which must raise OSError.

arigo commits-noreply at bitbucket.org
Fri Jan 21 17:46:22 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r41166:64c59c303cdc
Date: 2011-01-21 17:45 +0100
http://bitbucket.org/pypy/pypy/changeset/64c59c303cdc/

Log:	Handle failure cases, which must raise OSError.

diff --git a/pypy/rpython/module/ll_os.py b/pypy/rpython/module/ll_os.py
--- a/pypy/rpython/module/ll_os.py
+++ b/pypy/rpython/module/ll_os.py
@@ -613,7 +613,13 @@
         c_sysconf = self.llexternal('sysconf', [rffi.INT], rffi.LONG)
 
         def sysconf_llimpl(i):
-            return c_sysconf(i)
+            rposix.set_errno(0)
+            res = c_sysconf(i)
+            if res == -1:
+                errno = rposix.get_errno()
+                if errno != 0:
+                    raise OSError(errno, "sysconf failed")
+            return res
         return extdef([int], int, "ll_os.ll_sysconf", llimpl=sysconf_llimpl)
 
     @registering_if(os, 'fpathconf')
@@ -622,7 +628,13 @@
                                       [rffi.INT, rffi.INT], rffi.LONG)
 
         def fpathconf_llimpl(fd, i):
-            return c_fpathconf(fd, i)
+            rposix.set_errno(0)
+            res = c_fpathconf(fd, i)
+            if res == -1:
+                errno = rposix.get_errno()
+                if errno != 0:
+                    raise OSError(errno, "fpathconf failed")
+            return res
         return extdef([int, int], int, "ll_os.ll_fpathconf",
                       llimpl=fpathconf_llimpl)
 


More information about the Pypy-commit mailing list