[pypy-svn] r60999 - pypy/trunk/pypy/lib

fijal at codespeak.net fijal at codespeak.net
Thu Jan 15 15:53:20 CET 2009


Author: fijal
Date: Thu Jan 15 15:53:19 2009
New Revision: 60999

Modified:
   pypy/trunk/pypy/lib/resource.py
Log:
a bit more cpythonlike


Modified: pypy/trunk/pypy/lib/resource.py
==============================================================================
--- pypy/trunk/pypy/lib/resource.py	(original)
+++ pypy/trunk/pypy/lib/resource.py	Thu Jan 15 15:53:19 2009
@@ -7,6 +7,9 @@
     SimpleType)
 import _structseq
 
+class error(Exception):
+    pass
+
 _CONSTANTS = (
     'RLIM_INFINITY',
     'RLIM_NLIMITS',
@@ -66,10 +69,6 @@
         optional_constants.append(key)
 del config
 
-class ResourceError(OSError):
-    def __init__(self, errno):
-        OSError.__init__(self, errno)
-
 class timeval(Structure):
     _fields_ = (
         ("tv_sec", c_int),
@@ -134,7 +133,7 @@
         errno = get_errno()
         if errno == EINVAL:
             raise ValueError("invalid who parameter")
-        raise ResourceError(errno)
+        raise error(errno)
     return struct_rusage((
         float(ru.ru_utime),
         float(ru.ru_stime),
@@ -162,7 +161,7 @@
     ret = _getrlimit(resource, byref(rlim))
     if ret == -1:
         errno = get_errno()
-        raise ResourceError(errno)
+        raise error(errno)
     return (rlim.rlim_cur, rlim.rlim_max)
 
 def setrlimit(resource, rlim):
@@ -178,7 +177,7 @@
         elif errno == EPERM:
             return ValueError("not allowed to raise maximum limit")
         else:
-            raise ResourceError(errno)
+            raise error(errno)
 
 def getpagesize():
     pagesize = 0
@@ -192,7 +191,7 @@
             return sysconf("SC_PAGESIZE")
 
 __all__ = _CONSTANTS + tuple(optional_constants) + (
-    'ResourceError', 'timeval', 'struct_rusage', 'rlimit',
+    'error', 'timeval', 'struct_rusage', 'rlimit',
     'getrusage', 'getrlimit', 'setrlimit', 'getpagesize',
 )
 



More information about the Pypy-commit mailing list