diff options
author | Alexandre Vassalotti <alexandre@peadrop.com> | 2008-12-27 09:09:15 (GMT) |
---|---|---|
committer | Alexandre Vassalotti <alexandre@peadrop.com> | 2008-12-27 09:09:15 (GMT) |
commit | 9cb6f7f7a5afd587820ca378ad1129427f25b58f (patch) | |
tree | b3e03f31300c7832468421c416b75181783f6fb6 /Objects | |
parent | 554d878b1c653c98b6bd043cea67a4191ba114d0 (diff) | |
download | cpython-9cb6f7f7a5afd587820ca378ad1129427f25b58f.zip cpython-9cb6f7f7a5afd587820ca378ad1129427f25b58f.tar.gz cpython-9cb6f7f7a5afd587820ca378ad1129427f25b58f.tar.bz2 |
Fix wrong bytes type conversion in PyUnicode_AsUnicodeEscapeString.
Fix wrong bytes type conversion in PyUnicode_AsUnicodeDecodeString.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/unicodeobject.c | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 4a5aec7..e57b60c 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -3257,20 +3257,14 @@ PyObject *PyUnicode_EncodeUnicodeEscape(const Py_UNICODE *s, PyObject *PyUnicode_AsUnicodeEscapeString(PyObject *unicode) { - PyObject *s, *result; + PyObject *s; if (!PyUnicode_Check(unicode)) { PyErr_BadArgument(); return NULL; } s = PyUnicode_EncodeUnicodeEscape(PyUnicode_AS_UNICODE(unicode), PyUnicode_GET_SIZE(unicode)); - - if (!s) - return NULL; - result = PyBytes_FromStringAndSize(PyByteArray_AS_STRING(s), - PyByteArray_GET_SIZE(s)); - Py_DECREF(s); - return result; + return s; } /* --- Raw Unicode Escape Codec ------------------------------------------- */ @@ -3482,7 +3476,7 @@ PyObject *PyUnicode_EncodeRawUnicodeEscape(const Py_UNICODE *s, PyObject *PyUnicode_AsRawUnicodeEscapeString(PyObject *unicode) { - PyObject *s, *result; + PyObject *s; if (!PyUnicode_Check(unicode)) { PyErr_BadArgument(); return NULL; @@ -3490,12 +3484,7 @@ PyObject *PyUnicode_AsRawUnicodeEscapeString(PyObject *unicode) s = PyUnicode_EncodeRawUnicodeEscape(PyUnicode_AS_UNICODE(unicode), PyUnicode_GET_SIZE(unicode)); - if (!s) - return NULL; - result = PyBytes_FromStringAndSize(PyByteArray_AS_STRING(s), - PyByteArray_GET_SIZE(s)); - Py_DECREF(s); - return result; + return s; } /* --- Unicode Internal Codec ------------------------------------------- */ |