Mercurial > cpython-lru_cache-weakref
comparison Python/pythonrun.c @ 36751:8e04de2480e4 legacy-trunk
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.
| author | Brett Cannon <bcannon@gmail.com> |
|---|---|
| date | Wed, 01 Mar 2006 04:25:17 +0000 |
| parents | bbf16fd024df |
| children | d6c30ce3868b |
comparison
equal
deleted
inserted
replaced
| 36750:92ba72484ff3 | 36751:8e04de2480e4 |
|---|---|
| 974 if (Py_FlushLine()) | 974 if (Py_FlushLine()) |
| 975 PyErr_Clear(); | 975 PyErr_Clear(); |
| 976 fflush(stdout); | 976 fflush(stdout); |
| 977 if (value == NULL || value == Py_None) | 977 if (value == NULL || value == Py_None) |
| 978 goto done; | 978 goto done; |
| 979 if (PyInstance_Check(value)) { | 979 if (PyExceptionInstance_Check(value)) { |
| 980 /* The error code should be in the `code' attribute. */ | 980 /* The error code should be in the `code' attribute. */ |
| 981 PyObject *code = PyObject_GetAttrString(value, "code"); | 981 PyObject *code = PyObject_GetAttrString(value, "code"); |
| 982 if (code) { | 982 if (code) { |
| 983 Py_DECREF(value); | 983 Py_DECREF(value); |
| 984 value = code; | 984 value = code; |
| 1104 } | 1104 } |
| 1105 } | 1105 } |
| 1106 if (err) { | 1106 if (err) { |
| 1107 /* Don't do anything else */ | 1107 /* Don't do anything else */ |
| 1108 } | 1108 } |
| 1109 else if (PyClass_Check(exception)) { | 1109 else if (PyExceptionClass_Check(exception)) { |
| 1110 PyClassObject* exc = (PyClassObject*)exception; | 1110 char* className = PyExceptionClass_Name(exception); |
| 1111 PyObject* className = exc->cl_name; | |
| 1112 PyObject* moduleName = | 1111 PyObject* moduleName = |
| 1113 PyDict_GetItemString(exc->cl_dict, "__module__"); | 1112 PyObject_GetAttrString(exception, "__module__"); |
| 1114 | 1113 |
| 1115 if (moduleName == NULL) | 1114 if (moduleName == NULL) |
| 1116 err = PyFile_WriteString("<unknown>", f); | 1115 err = PyFile_WriteString("<unknown>", f); |
| 1117 else { | 1116 else { |
| 1118 char* modstr = PyString_AsString(moduleName); | 1117 char* modstr = PyString_AsString(moduleName); |
| 1124 } | 1123 } |
| 1125 if (err == 0) { | 1124 if (err == 0) { |
| 1126 if (className == NULL) | 1125 if (className == NULL) |
| 1127 err = PyFile_WriteString("<unknown>", f); | 1126 err = PyFile_WriteString("<unknown>", f); |
| 1128 else | 1127 else |
| 1129 err = PyFile_WriteObject(className, f, | 1128 err = PyFile_WriteString(className, f); |
| 1130 Py_PRINT_RAW); | |
| 1131 } | 1129 } |
| 1132 } | 1130 } |
| 1133 else | 1131 else |
| 1134 err = PyFile_WriteObject(exception, f, Py_PRINT_RAW); | 1132 err = PyFile_WriteObject(exception, f, Py_PRINT_RAW); |
| 1135 if (err == 0) { | 1133 if (err == 0) { |
