diff Python/errors.c @ 41878:089f449a20cd

Change PyErr_Format() to generate a unicode string (by using PyUnicode_FromFormatV() instead of PyString_FromFormatV()). Change calls to PyErr_Format() to benefit from the new format specifiers: Using %S, object instead of %s, PyString_AS_STRING(object) with will work with unicode objects too.
author Walter Dörwald <walter@livinglogic.de>
date Fri, 25 May 2007 15:46:59 +0000
parents b29d71d43c80
children 854cc4d5a33d
line wrap: on
line diff
--- a/Python/errors.c	Fri May 25 14:14:31 2007 +0000
+++ b/Python/errors.c	Fri May 25 15:46:59 2007 +0000
@@ -54,11 +54,9 @@
 {
 	if (exception != NULL &&
 	    !PyExceptionClass_Check(exception)) {
-		PyObject *excstr = PyObject_ReprStr8(exception);
 		PyErr_Format(PyExc_SystemError,
-			     "exception %s not a BaseException subclass",
-			     PyString_AS_STRING(excstr));
-		Py_DECREF(excstr);
+			     "exception %R not a BaseException subclass",
+			     exception);
 		return;
 	}
 	Py_XINCREF(exception);
@@ -75,7 +73,7 @@
 void
 PyErr_SetString(PyObject *exception, const char *string)
 {
-	PyObject *value = PyString_FromString(string);
+	PyObject *value = PyUnicode_FromString(string);
 	PyErr_SetObject(exception, value);
 	Py_XDECREF(value);
 }
@@ -528,7 +526,7 @@
 	va_start(vargs);
 #endif
 
-	string = PyString_FromFormatV(format, vargs);
+	string = PyUnicode_FromFormatV(format, vargs);
 	PyErr_SetObject(exception, string);
 	Py_XDECREF(string);
 	va_end(vargs);