comparison Python/codecs.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 15b810e21fe9
children 36b8d74deb9e
comparison
equal deleted inserted replaced
41877:1ec1afa2bdb5 41878:089f449a20cd
441 441
442 static void wrong_exception_type(PyObject *exc) 442 static void wrong_exception_type(PyObject *exc)
443 { 443 {
444 PyObject *type = PyObject_GetAttrString(exc, "__class__"); 444 PyObject *type = PyObject_GetAttrString(exc, "__class__");
445 if (type != NULL) { 445 if (type != NULL) {
446 PyObject *name = PyObject_GetAttrString(type, "__name__"); 446 PyObject *name = PyObject_GetAttrString(type, "__name__");
447 Py_DECREF(type); 447 Py_DECREF(type);
448 if (name != NULL) { 448 if (name != NULL) {
449 PyObject *string = PyObject_Str(name); 449 PyErr_Format(PyExc_TypeError,
450 Py_DECREF(name); 450 "don't know how to handle %S in error callback", name);
451 if (string != NULL) { 451 Py_DECREF(name);
452 PyErr_Format(PyExc_TypeError, 452 }
453 "don't know how to handle %.400s in error callback",
454 PyString_AS_STRING(string));
455 Py_DECREF(string);
456 }
457 }
458 } 453 }
459 } 454 }
460 455
461 PyObject *PyCodec_StrictErrors(PyObject *exc) 456 PyObject *PyCodec_StrictErrors(PyObject *exc)
462 { 457 {