[Python-checkins] r55151 - python/branches/py3k-struni/Objects/unicodeobject.c

walter.doerwald python-checkins at python.org
Sat May 5 16:43:41 CEST 2007


Author: walter.doerwald
Date: Sat May  5 16:43:36 2007
New Revision: 55151

Modified:
   python/branches/py3k-struni/Objects/unicodeobject.c
Log:
Change PyUnicode_EncodeUTF7() to return a bytes object.


Modified: python/branches/py3k-struni/Objects/unicodeobject.c
==============================================================================
--- python/branches/py3k-struni/Objects/unicodeobject.c	(original)
+++ python/branches/py3k-struni/Objects/unicodeobject.c	Sat May  5 16:43:36 2007
@@ -1149,13 +1149,13 @@
     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 @@
         *out++ = '-';
     }
 
-    _PyString_Resize(&v, out - start);
+    if (PyBytes_Resize(v, out - start)) {
+        Py_DECREF(v);
+        return NULL;
+    }
     return v;
 }
 


More information about the Python-checkins mailing list