diff options
author | Walter Dörwald <walter@livinglogic.de> | 2007-05-18 17:15:44 +0000 |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2007-05-18 17:15:44 +0000 |
commit | 1ab833082738ced53318aca05901e596d5ede683 (patch) | |
tree | 0ff2b4c1fcbab3233e012f04bce801cadfd6d7f9 /Objects/exceptions.c | |
parent | 14176a56d3fe36388115688d0b5acae0c759c044 (diff) | |
download | cpython-git-1ab833082738ced53318aca05901e596d5ede683.tar.gz |
Add functions PyUnicode_Append() and PyUnicode_AppendAndDel() that mirror
PyString_Concat() and PyString_ConcatAndDel() (the name PyUnicode_Concat()
was already taken).
Change PyObject_Repr() to always return a unicode object.
Update all repr implementations to return unicode objects.
Add a function PyObject_ReprStr8() that calls PyObject_Repr() and converts
the result to an 8bit string.
Use PyObject_ReprStr8() where using PyObject_Repr() can't be done
straightforward.
Diffstat (limited to 'Objects/exceptions.c')
-rw-r--r-- | Objects/exceptions.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c index 36e37955dc..f4c265a329 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -111,13 +111,13 @@ BaseException_repr(PyBaseExceptionObject *self) dot = strrchr(name, '.'); if (dot != NULL) name = dot+1; - repr = PyString_FromString(name); + repr = PyUnicode_FromString(name); if (!repr) { Py_DECREF(repr_suffix); return NULL; } - PyString_ConcatAndDel(&repr, repr_suffix); + PyUnicode_AppendAndDel(&repr, repr_suffix); return repr; } @@ -529,7 +529,7 @@ EnvironmentError_str(PyEnvironmentErrorObject *self) if (!fmt) return NULL; - repr = PyObject_Repr(self->filename); + repr = PyObject_ReprStr8(self->filename); if (!repr) { Py_DECREF(fmt); return NULL; @@ -760,7 +760,7 @@ WindowsError_str(PyWindowsErrorObject *self) if (!fmt) return NULL; - repr = PyObject_Repr(self->filename); + repr = PyObject_ReprStr8(self->filename); if (!repr) { Py_DECREF(fmt); return NULL; @@ -1134,7 +1134,7 @@ KeyError_str(PyBaseExceptionObject *self) If args is anything else, use the default BaseException__str__(). */ if (PyTuple_GET_SIZE(self->args) == 1) { - return PyObject_Repr(PyTuple_GET_ITEM(self->args, 0)); + return PyObject_ReprStr8(PyTuple_GET_ITEM(self->args, 0)); } return BaseException_str(self); } |