diff options
author | Walter Dörwald <walter@livinglogic.de> | 2007-05-25 15:46:59 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2007-05-25 15:46:59 (GMT) |
commit | 573c08c1b73048876b62d99ff8d82337dc8ce0a2 (patch) | |
tree | a66a43f5e3f362acb738877ab1551d69dc5e5450 /Python/errors.c | |
parent | e65c86cca02a6cc5698ecf846d6340319e5fd803 (diff) | |
download | cpython-573c08c1b73048876b62d99ff8d82337dc8ce0a2.zip cpython-573c08c1b73048876b62d99ff8d82337dc8ce0a2.tar.gz cpython-573c08c1b73048876b62d99ff8d82337dc8ce0a2.tar.bz2 |
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.
Diffstat (limited to 'Python/errors.c')
-rw-r--r-- | Python/errors.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/Python/errors.c b/Python/errors.c index 4ef491f..2a84c8d 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -54,11 +54,9 @@ PyErr_SetObject(PyObject *exception, PyObject *value) { 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 @@ PyErr_SetNone(PyObject *exception) 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 @@ PyErr_Format(PyObject *exception, const char *format, ...) va_start(vargs); #endif - string = PyString_FromFormatV(format, vargs); + string = PyUnicode_FromFormatV(format, vargs); PyErr_SetObject(exception, string); Py_XDECREF(string); va_end(vargs); |