mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
PEP 352 implementation. Creates a new base class, BaseException, which has an
added message attribute compared to the previous version of Exception. It is also a new-style class, making all exceptions now new-style. KeyboardInterrupt and SystemExit inherit from BaseException directly. String exceptions now raise DeprecationWarning. Applies patch 1104669, and closes bugs 1012952 and 518846.
This commit is contained in:
parent
762467475d
commit
bf36409e2a
16 changed files with 570 additions and 232 deletions
|
|
@ -26,9 +26,32 @@ PyAPI_FUNC(int) PyErr_GivenExceptionMatches(PyObject *, PyObject *);
|
|||
PyAPI_FUNC(int) PyErr_ExceptionMatches(PyObject *);
|
||||
PyAPI_FUNC(void) PyErr_NormalizeException(PyObject**, PyObject**, PyObject**);
|
||||
|
||||
/* */
|
||||
|
||||
#define PyExceptionClass_Check(x) \
|
||||
(PyClass_Check((x)) \
|
||||
|| (PyType_Check((x)) && PyType_IsSubtype( \
|
||||
(PyTypeObject*)(x), (PyTypeObject*)PyExc_BaseException)))
|
||||
|
||||
|
||||
#define PyExceptionInstance_Check(x) \
|
||||
(PyInstance_Check((x)) || \
|
||||
(PyType_IsSubtype((x)->ob_type, (PyTypeObject*)PyExc_BaseException)))
|
||||
|
||||
#define PyExceptionClass_Name(x) \
|
||||
(PyClass_Check((x)) \
|
||||
? PyString_AS_STRING(((PyClassObject*)(x))->cl_name) \
|
||||
: (char *)(((PyTypeObject*)(x))->tp_name))
|
||||
|
||||
#define PyExceptionInstance_Class(x) \
|
||||
((PyInstance_Check((x)) \
|
||||
? (PyObject*)((PyInstanceObject*)(x))->in_class \
|
||||
: (PyObject*)((x)->ob_type)))
|
||||
|
||||
|
||||
/* Predefined exceptions */
|
||||
|
||||
PyAPI_DATA(PyObject *) PyExc_BaseException;
|
||||
PyAPI_DATA(PyObject *) PyExc_Exception;
|
||||
PyAPI_DATA(PyObject *) PyExc_StopIteration;
|
||||
PyAPI_DATA(PyObject *) PyExc_GeneratorExit;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue