Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0474832

Browse files
committed
Introduce PyExc_Exception as the conceptual root class for all exceptions.
1 parent c56ba38 commit 0474832

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

Include/pyerrors.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ void PyErr_NormalizeException Py_PROTO((PyObject**, PyObject**, PyObject**));
5353

5454
/* Predefined exceptions */
5555

56+
extern DL_IMPORT(PyObject *) PyExc_Exception;
5657
extern DL_IMPORT(PyObject *) PyExc_StandardError;
5758
extern DL_IMPORT(PyObject *) PyExc_NumberError;
5859
extern DL_IMPORT(PyObject *) PyExc_LookupError;

Python/bltinmodule.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,6 +1724,7 @@ static PyMethodDef builtin_methods[] = {
17241724

17251725
/* Predefined exceptions */
17261726

1727+
PyObject *PyExc_Exception;
17271728
PyObject *PyExc_StandardError;
17281729
PyObject *PyExc_NumberError;
17291730
PyObject *PyExc_LookupError;
@@ -1757,6 +1758,7 @@ static struct
17571758
int leaf_exc;
17581759
}
17591760
bltin_exc[] = {
1761+
{"Exception", &PyExc_Exception, 0},
17601762
{"StandardError", &PyExc_StandardError, 0},
17611763
{"NumberError", &PyExc_NumberError, 0},
17621764
{"LookupError", &PyExc_LookupError, 0},
@@ -1901,6 +1903,11 @@ initerrors(dict)
19011903
PyTuple_SET_ITEM(PyExc_StandardError, i-1, exc);
19021904
}
19031905
PyDict_SetItemString(dict, "StandardError", PyExc_StandardError);
1906+
1907+
/* Exception is treated differently; for now, it's == StandardError */
1908+
PyExc_Exception = PyExc_StandardError;
1909+
Py_INCREF(PyExc_Exception);
1910+
PyDict_SetItemString(dict, "Exception", PyExc_Exception);
19041911

19051912
if (PyErr_Occurred())
19061913
Py_FatalError("Could not initialize built-in string exceptions");

0 commit comments

Comments
 (0)