mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Introduce PyExc_Exception as the conceptual root class for all exceptions.
This commit is contained in:
parent
c56ba38350
commit
0474832d9c
2 changed files with 8 additions and 0 deletions
|
@ -53,6 +53,7 @@ void PyErr_NormalizeException Py_PROTO((PyObject**, PyObject**, PyObject**));
|
||||||
|
|
||||||
/* Predefined exceptions */
|
/* Predefined exceptions */
|
||||||
|
|
||||||
|
extern DL_IMPORT(PyObject *) PyExc_Exception;
|
||||||
extern DL_IMPORT(PyObject *) PyExc_StandardError;
|
extern DL_IMPORT(PyObject *) PyExc_StandardError;
|
||||||
extern DL_IMPORT(PyObject *) PyExc_NumberError;
|
extern DL_IMPORT(PyObject *) PyExc_NumberError;
|
||||||
extern DL_IMPORT(PyObject *) PyExc_LookupError;
|
extern DL_IMPORT(PyObject *) PyExc_LookupError;
|
||||||
|
|
|
@ -1724,6 +1724,7 @@ static PyMethodDef builtin_methods[] = {
|
||||||
|
|
||||||
/* Predefined exceptions */
|
/* Predefined exceptions */
|
||||||
|
|
||||||
|
PyObject *PyExc_Exception;
|
||||||
PyObject *PyExc_StandardError;
|
PyObject *PyExc_StandardError;
|
||||||
PyObject *PyExc_NumberError;
|
PyObject *PyExc_NumberError;
|
||||||
PyObject *PyExc_LookupError;
|
PyObject *PyExc_LookupError;
|
||||||
|
@ -1757,6 +1758,7 @@ static struct
|
||||||
int leaf_exc;
|
int leaf_exc;
|
||||||
}
|
}
|
||||||
bltin_exc[] = {
|
bltin_exc[] = {
|
||||||
|
{"Exception", &PyExc_Exception, 0},
|
||||||
{"StandardError", &PyExc_StandardError, 0},
|
{"StandardError", &PyExc_StandardError, 0},
|
||||||
{"NumberError", &PyExc_NumberError, 0},
|
{"NumberError", &PyExc_NumberError, 0},
|
||||||
{"LookupError", &PyExc_LookupError, 0},
|
{"LookupError", &PyExc_LookupError, 0},
|
||||||
|
@ -1901,6 +1903,11 @@ initerrors(dict)
|
||||||
PyTuple_SET_ITEM(PyExc_StandardError, i-1, exc);
|
PyTuple_SET_ITEM(PyExc_StandardError, i-1, exc);
|
||||||
}
|
}
|
||||||
PyDict_SetItemString(dict, "StandardError", PyExc_StandardError);
|
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())
|
if (PyErr_Occurred())
|
||||||
Py_FatalError("Could not initialize built-in string exceptions");
|
Py_FatalError("Could not initialize built-in string exceptions");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue