]> granicus.if.org Git - python/commitdiff
alias resource.error to OSError
authorBenjamin Peterson <benjamin@python.org>
Sat, 10 Dec 2011 22:50:22 +0000 (17:50 -0500)
committerBenjamin Peterson <benjamin@python.org>
Sat, 10 Dec 2011 22:50:22 +0000 (17:50 -0500)
Doc/library/resource.rst
Misc/NEWS
Modules/resource.c

index c16b01301eb18a22f299941d4841f992992c3377..03a7cb598cd49ee3a345db50c7ee41329169c7eb 100644 (file)
@@ -14,13 +14,15 @@ resources utilized by a program.
 Symbolic constants are used to specify particular system resources and to
 request usage information about either the current process or its children.
 
-A single exception is defined for errors:
+An :exc:`OSError` is raised on syscall failure.
 
 
 .. exception:: error
 
-   The functions described below may raise this error if the underlying system call
-   failures unexpectedly.
+   A deprecated alias of :exc:`OSError`.
+
+   .. versionchanged:: 3.3
+      Following :pep:`3151`, this class was made an alias of :exc:`OSError`.
 
 
 Resource Limits
index 58c281355b01cca70f18287b2bc688e2b059cd9e..16cda4232f85e39b803bbb1ef44362a889f24671 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -406,6 +406,8 @@ Core and Builtins
 Library
 -------
 
+- Alias resource.error to OSError ala PEP 3151.
+
 - Issue #13248: Turn 3.2's PendingDeprecationWarning into 3.3's
   DeprecationWarning.  It covers 'cgi.escape', 'importlib.abc.PyLoader',
   'importlib.abc.PyPycLoader', 'nntplib.NNTP.xgtitle', 'nntplib.NNTP.xpath',
index 1875e483f9b931344d17f834994874ccb69b37a7..1aed497f9bb829baa9c0cb7c3e80aa75d57dc7f9 100644 (file)
@@ -18,8 +18,6 @@
 
 #define doubletime(TV) ((double)(TV).tv_sec + (TV).tv_usec * 0.000001)
 
-static PyObject *ResourceError;
-
 PyDoc_STRVAR(struct_rusage__doc__,
 "struct_rusage: Result from getrusage.\n\n"
 "This object may be accessed either as a tuple of\n"
@@ -73,7 +71,7 @@ resource_getrusage(PyObject *self, PyObject *args)
                             "invalid who parameter");
             return NULL;
         }
-        PyErr_SetFromErrno(ResourceError);
+        PyErr_SetFromErrno(PyExc_OSError);
         return NULL;
     }
 
@@ -125,7 +123,7 @@ resource_getrlimit(PyObject *self, PyObject *args)
     }
 
     if (getrlimit(resource, &rl) == -1) {
-        PyErr_SetFromErrno(ResourceError);
+        PyErr_SetFromErrno(PyExc_OSError);
         return NULL;
     }
 
@@ -183,7 +181,7 @@ resource_setrlimit(PyObject *self, PyObject *args)
             PyErr_SetString(PyExc_ValueError,
                             "not allowed to raise maximum limit");
         else
-            PyErr_SetFromErrno(ResourceError);
+            PyErr_SetFromErrno(PyExc_OSError);
         return NULL;
     }
     Py_INCREF(Py_None);
@@ -246,12 +244,8 @@ PyInit_resource(void)
         return NULL;
 
     /* Add some symbolic constants to the module */
-    if (ResourceError == NULL) {
-        ResourceError = PyErr_NewException("resource.error",
-                                           NULL, NULL);
-    }
-    Py_INCREF(ResourceError);
-    PyModule_AddObject(m, "error", ResourceError);
+    Py_INCREF(PyExc_OSError);
+    PyModule_AddObject(m, "error", PyExc_OSError);
     if (!initialized)
         PyStructSequence_InitType(&StructRUsageType,
                                   &struct_rusage_desc);