diff Python/pythonrun.c @ 35418:37fa7b6dca9b 2.4

Forward UnicodeDecodeError into SyntaxError for source encoding errors.
author Martin v. Löwis <martin@v.loewis.de>
date Wed, 24 Aug 2005 08:39:46 +0000
parents 28892e6512ba
children 6c3d0a0c1956
line wrap: on
line diff
--- a/Python/pythonrun.c	Wed Aug 24 07:38:36 2005 +0000
+++ b/Python/pythonrun.c	Wed Aug 24 08:39:46 2005 +0000
@@ -1471,18 +1471,20 @@
 		errtype = PyExc_IndentationError;
 		msg = "too many levels of indentation";
 		break;
-	case E_DECODE: {	/* XXX */
-		PyThreadState* tstate = PyThreadState_GET();
-		PyObject* value = tstate->curexc_value;
+	case E_DECODE: {
+		PyObject *type, *value, *tb;
+		PyErr_Fetch(&type, &value, &tb);
 		if (value != NULL) {
-			u = PyObject_Repr(value);
+			u = PyObject_Str(value);
 			if (u != NULL) {
 				msg = PyString_AsString(u);
-				break;
 			}
 		}
 		if (msg == NULL)
 			msg = "unknown decode error";
+		Py_DECREF(type);
+		Py_DECREF(value);
+		Py_DECREF(tb);
 		break;
 	}
 	default: