]> granicus.if.org Git - python/commitdiff
Introduce PyExc_Exception as the conceptual root class for all exceptions.
authorGuido van Rossum <guido@python.org>
Tue, 16 Sep 1997 18:43:15 +0000 (18:43 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 16 Sep 1997 18:43:15 +0000 (18:43 +0000)
Include/pyerrors.h
Python/bltinmodule.c

index ece1f3fedbd4618bbfe21a9dd18ba6076f8f1c66..580f6d7da90a2f7afe6f2af57cb724dc25caad9e 100644 (file)
@@ -53,6 +53,7 @@ void PyErr_NormalizeException Py_PROTO((PyObject**, PyObject**, PyObject**));
 
 /* Predefined exceptions */
 
+extern DL_IMPORT(PyObject *) PyExc_Exception;
 extern DL_IMPORT(PyObject *) PyExc_StandardError;
 extern DL_IMPORT(PyObject *) PyExc_NumberError;
 extern DL_IMPORT(PyObject *) PyExc_LookupError;
index 251108ff4927f50b38a5359871c72f8ec5e84aa6..2c858ec689d73c3318f9ce2a4a168896dc8ea9e8 100644 (file)
@@ -1724,6 +1724,7 @@ static PyMethodDef builtin_methods[] = {
 
 /* Predefined exceptions */
 
+PyObject *PyExc_Exception;
 PyObject *PyExc_StandardError;
 PyObject *PyExc_NumberError;
 PyObject *PyExc_LookupError;
@@ -1757,6 +1758,7 @@ static struct
        int leaf_exc;
 }
 bltin_exc[] = {
+       {"Exception",          &PyExc_Exception,          0},
        {"StandardError",      &PyExc_StandardError,      0},
        {"NumberError",        &PyExc_NumberError,        0},
        {"LookupError",        &PyExc_LookupError,        0},
@@ -1901,6 +1903,11 @@ initerrors(dict)
                PyTuple_SET_ITEM(PyExc_StandardError, i-1, exc);
        }
        PyDict_SetItemString(dict, "StandardError", PyExc_StandardError);
+
+       /* Exception is treated differently; for now, it's == StandardError */
+       PyExc_Exception = PyExc_StandardError;
+       Py_INCREF(PyExc_Exception);
+       PyDict_SetItemString(dict, "Exception", PyExc_Exception);
        
        if (PyErr_Occurred())
              Py_FatalError("Could not initialize built-in string exceptions");