diff options
author | Walter Dörwald <walter@livinglogic.de> | 2007-05-05 14:43:36 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2007-05-05 14:43:36 (GMT) |
commit | 51ab4146275d9178a871317413f998aede952b7d (patch) | |
tree | ac791bdf40db31fb40a4b869307e26c779585392 /Objects | |
parent | ce32db3ab5ca95fa6de99bf8f12285b1a736223a (diff) | |
download | cpython-51ab4146275d9178a871317413f998aede952b7d.zip cpython-51ab4146275d9178a871317413f998aede952b7d.tar.gz cpython-51ab4146275d9178a871317413f998aede952b7d.tar.bz2 |
Change PyUnicode_EncodeUTF7() to return a bytes object.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/unicodeobject.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index aed07ee..af98a90 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -1149,13 +1149,13 @@ PyObject *PyUnicode_EncodeUTF7(const Py_UNICODE *s, char * start; if (size == 0) - return PyString_FromStringAndSize(NULL, 0); + return PyBytes_FromStringAndSize(NULL, 0); - v = PyString_FromStringAndSize(NULL, cbAllocated); + v = PyBytes_FromStringAndSize(NULL, cbAllocated); if (v == NULL) return NULL; - start = out = PyString_AS_STRING(v); + start = out = PyBytes_AS_STRING(v); for (;i < size; ++i) { Py_UNICODE ch = s[i]; @@ -1221,7 +1221,10 @@ PyObject *PyUnicode_EncodeUTF7(const Py_UNICODE *s, *out++ = '-'; } - _PyString_Resize(&v, out - start); + if (PyBytes_Resize(v, out - start)) { + Py_DECREF(v); + return NULL; + } return v; } |