summaryrefslogtreecommitdiff
path: root/Python/errors.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-07-17 13:44:17 +0300
committerSerhiy Storchaka <storchaka@gmail.com>2013-07-17 13:44:17 +0300
commitf582ba10a37c0bad1c62461e57e6424f72716a58 (patch)
tree3e569585c5d93cf0ce8f27ad2286d0dd6c53ea04 /Python/errors.c
parent7315264da2e4f1be630bd641fde745c8c0d485d1 (diff)
parentaeae099f325e5540a53f04d168dc4f7a068ce87c (diff)
downloadcpython-f582ba10a37c0bad1c62461e57e6424f72716a58.tar.gz
Issue #18266: test_largefile now works with unittest test discovery and
supports running only selected tests. Patch by Zachary Ware.
Diffstat (limited to 'Python/errors.c')
-rw-r--r--Python/errors.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/Python/errors.c b/Python/errors.c
index 626b16e46f..53dd9a9650 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -227,12 +227,21 @@ PyErr_NormalizeException(PyObject **exc, PyObject **val, PyObject **tb)
value will be an instance.
*/
if (PyExceptionClass_Check(type)) {
+ int is_subclass;
+ if (inclass) {
+ is_subclass = PyObject_IsSubclass(inclass, type);
+ if (is_subclass < 0)
+ goto finally;
+ }
+ else
+ is_subclass = 0;
+
/* if the value was not an instance, or is not an instance
whose class is (or is derived from) type, then use the
value as an argument to instantiation of the type
class.
*/
- if (!inclass || !PyObject_IsSubclass(inclass, type)) {
+ if (!inclass || !is_subclass) {
PyObject *args, *res;
if (value == Py_None)
@@ -588,7 +597,7 @@ PyObject *PyErr_SetExcFromWindowsErr(PyObject *exc, int ierr)
PyObject *PyErr_SetFromWindowsErr(int ierr)
{
- return PyErr_SetExcFromWindowsErrWithFilename(PyExc_WindowsError,
+ return PyErr_SetExcFromWindowsErrWithFilename(PyExc_OSError,
ierr, NULL);
}
PyObject *PyErr_SetFromWindowsErrWithFilename(
@@ -597,7 +606,7 @@ PyObject *PyErr_SetFromWindowsErrWithFilename(
{
PyObject *name = filename ? PyUnicode_DecodeFSDefault(filename) : NULL;
PyObject *result = PyErr_SetExcFromWindowsErrWithFilenameObject(
- PyExc_WindowsError,
+ PyExc_OSError,
ierr, name);
Py_XDECREF(name);
return result;
@@ -611,7 +620,7 @@ PyObject *PyErr_SetFromWindowsErrWithUnicodeFilename(
PyUnicode_FromUnicode(filename, wcslen(filename)) :
NULL;
PyObject *result = PyErr_SetExcFromWindowsErrWithFilenameObject(
- PyExc_WindowsError,
+ PyExc_OSError,
ierr, name);
Py_XDECREF(name);
return result;
@@ -675,6 +684,7 @@ _PyErr_BadInternalCall(const char *filename, int lineno)
void
PyErr_BadInternalCall(void)
{
+ assert(0 && "bad argument to internal function");
PyErr_Format(PyExc_SystemError,
"bad argument to internal function");
}
@@ -798,7 +808,12 @@ PyErr_WriteUnraisable(PyObject *obj)
PyErr_Fetch(&t, &v, &tb);
f = PySys_GetObject("stderr");
if (f != NULL && f != Py_None) {
- PyFile_WriteString("Exception ", f);
+ if (obj) {
+ PyFile_WriteString("Exception ignored in: ", f);
+ PyFile_WriteObject(obj, f, 0);
+ PyFile_WriteString("\n", f);
+ }
+ PyTraceBack_Print(tb, f);
if (t) {
PyObject* moduleName;
char* className;
@@ -828,15 +843,11 @@ PyErr_WriteUnraisable(PyObject *obj)
PyFile_WriteString(className, f);
if (v && v != Py_None) {
PyFile_WriteString(": ", f);
- PyFile_WriteObject(v, f, 0);
+ PyFile_WriteObject(v, f, Py_PRINT_RAW);
}
+ PyFile_WriteString("\n", f);
Py_XDECREF(moduleName);
}
- if (obj) {
- PyFile_WriteString(" in ", f);
- PyFile_WriteObject(obj, f, 0);
- }
- PyFile_WriteString(" ignored\n", f);
PyErr_Clear(); /* Just in case */
}
Py_XDECREF(t);