[Python-checkins] r67997 - sandbox/trunk/io-c/_textio.c

amaury.forgeotdarc python-checkins at python.org
Mon Dec 29 00:36:20 CET 2008


Author: amaury.forgeotdarc
Date: Mon Dec 29 00:36:20 2008
New Revision: 67997

Log:
Use the "internal" TextIOWrapper_get_decoded_chars API in TextIOWrapper.read().
This fixes one test


Modified:
   sandbox/trunk/io-c/_textio.c

Modified: sandbox/trunk/io-c/_textio.c
==============================================================================
--- sandbox/trunk/io-c/_textio.c	(original)
+++ sandbox/trunk/io-c/_textio.c	Mon Dec 29 00:36:20 2008
@@ -738,6 +738,11 @@
     if (!PyArg_ParseTuple(args, "|n:read", &n))
         return NULL;
 
+    result = TextIOWrapper_get_decoded_chars(self, -1);
+
+    if (result == NULL)
+	return NULL;
+
     if (n < 0) {
         /* Read everything */
         PyObject *bytes = PyObject_CallMethod(self->buffer, "read", NULL);
@@ -747,22 +752,15 @@
         decoded = PyObject_CallMethod(self->decoder, "decode",
 				      "Oi", bytes, /*final=*/1);
 
-        if (self->decoded_chars) {
-            result = PyNumber_Add(self->decoded_chars, decoded);
-            if (result == NULL)
-                goto fail;
-            Py_CLEAR(self->decoded_chars);
-            Py_DECREF(decoded);
-        }
-        else {
-            result = decoded;
-        }
+	PyUnicode_AppendAndDel(&result, decoded);
+	if (result == NULL)
+	    goto fail;
+
         Py_CLEAR(self->snapshot);
         return result;
     }
     else {
         int res = 1;
-        PyObject *result = TextIOWrapper_get_decoded_chars(self, -1);
 
         /* Keep reading chunks until we have n characters to return */
         while (res == 1) {


More information about the Python-checkins mailing list