diff -r 4a6709a071d0 Lib/test/test_generators.py --- a/Lib/test/test_generators.py Thu Oct 13 13:38:14 2011 +0200 +++ b/Lib/test/test_generators.py Sat Oct 15 12:37:50 2011 +0200 @@ -1744,9 +1744,7 @@ >>> g = f() >>> next(g) >>> del g ->>> sys.stderr.getvalue().startswith( -... "Exception RuntimeError: 'generator ignored GeneratorExit' in " -... ) +>>> "generator ignored GeneratorExit" in sys.stderr.getvalue() True >>> sys.stderr = old @@ -1860,17 +1858,15 @@ ... ... l = Leaker() ... del l -... err = sys.stderr.getvalue().strip() -... err.startswith( -... "Exception RuntimeError: RuntimeError() in <" -... ) -... err.endswith("> ignored") -... len(err.splitlines()) +... err = sys.stderr.getvalue() +... "Class: RuntimeError" in err +... "Instance: RuntimeError()" in err +... "Traceback" in err ... finally: ... sys.stderr = old True True -1 +True diff -r 4a6709a071d0 Python/errors.c --- a/Python/errors.c Thu Oct 13 13:38:14 2011 +0200 +++ b/Python/errors.c Sat Oct 15 12:37:50 2011 +0200 @@ -717,7 +717,7 @@ PyErr_Fetch(&t, &v, &tb); f = PySys_GetObject("stderr"); if (f != NULL && f != Py_None) { - PyFile_WriteString("Exception ", f); + PyFile_WriteString("-----BEGIN UNRAISABLE EXCEPTION-----\n", f); if (t) { PyObject* moduleName; char* className; @@ -729,6 +729,7 @@ className = dot+1; } + PyFile_WriteString("Class: ", f); moduleName = _PyObject_GetAttrId(t, &PyId___module__); if (moduleName == NULL) PyFile_WriteString("", f); @@ -745,18 +746,20 @@ PyFile_WriteString("", f); else PyFile_WriteString(className, f); + PyFile_WriteString("\nInstance: ", f); if (v && v != Py_None) { - PyFile_WriteString(": ", f); PyFile_WriteObject(v, f, 0); } Py_XDECREF(moduleName); } if (obj) { - PyFile_WriteString(" in ", f); + PyFile_WriteString("\nFunction: ", f); PyFile_WriteObject(obj, f, 0); } - PyFile_WriteString(" ignored\n", f); - PyErr_Clear(); /* Just in case */ + PyFile_WriteString("\n", f); + PyTraceBack_Print(tb,f); + PyFile_WriteString("-----END UNRAISABLE EXCEPTION-----\n", f); + PyErr_Clear(); /* Just in case */ } Py_XDECREF(t); Py_XDECREF(v);