diff Objects/unicodeobject.c @ 50292:665c4ac47073

Fix wrong bytes type conversion in PyUnicode_AsUnicodeEscapeString. Fix wrong bytes type conversion in PyUnicode_AsUnicodeDecodeString.
author Alexandre Vassalotti <alexandre@peadrop.com>
date Sat, 27 Dec 2008 09:09:15 +0000
parents adb9b547c7fe
children db50dc0061ed
line wrap: on
line diff
--- a/Objects/unicodeobject.c	Sat Dec 27 07:32:41 2008 +0000
+++ b/Objects/unicodeobject.c	Sat Dec 27 09:09:15 2008 +0000
@@ -3257,20 +3257,14 @@
 
 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_AsRawUnicodeEscapeString(PyObject *unicode)
 {
-    PyObject *s, *result;
+    PyObject *s;
     if (!PyUnicode_Check(unicode)) {
         PyErr_BadArgument();
         return NULL;
@@ -3490,12 +3484,7 @@
     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 ------------------------------------------- */