[Python-checkins] r46433 - python/trunk/Modules/_codecsmodule.c

martin.v.loewis python-checkins at python.org
Sat May 27 10:54:30 CEST 2006


Author: martin.v.loewis
Date: Sat May 27 10:54:29 2006
New Revision: 46433

Modified:
   python/trunk/Modules/_codecsmodule.c
Log:
Explain why 'consumed' is initialized.


Modified: python/trunk/Modules/_codecsmodule.c
==============================================================================
--- python/trunk/Modules/_codecsmodule.c	(original)
+++ python/trunk/Modules/_codecsmodule.c	Sat May 27 10:54:29 2006
@@ -319,12 +319,11 @@
     if (!PyArg_ParseTuple(args, "t#|zi:utf_16_decode",
 			  &data, &size, &errors, &final))
 	return NULL;
-    /* XXX Why is consumed initialized to size? mvl */
     if (size < 0) {
 	    PyErr_SetString(PyExc_ValueError, "negative argument");
 	    return 0;
     }
-    consumed = size;
+    consumed = size; /* This is overwritten unless final is true. */
     decoded = PyUnicode_DecodeUTF16Stateful(data, size, errors, &byteorder,
 					    final ? NULL : &consumed);
     if (decoded == NULL)
@@ -348,12 +347,11 @@
 			  &data, &size, &errors, &final))
 	return NULL;
 
-    /* XXX Why is consumed initialized to size? mvl */
     if (size < 0) {
           PyErr_SetString(PyExc_ValueError, "negative argument");
           return 0;
     }
-    consumed = size;
+    consumed = size; /* This is overwritten unless final is true. */
     decoded = PyUnicode_DecodeUTF16Stateful(data, size, errors,
 	&byteorder, final ? NULL : &consumed);
     if (decoded == NULL)
@@ -377,12 +375,11 @@
     if (!PyArg_ParseTuple(args, "t#|zi:utf_16_be_decode",
 			  &data, &size, &errors, &final))
 	return NULL;
-    /* XXX Why is consumed initialized to size? mvl */
     if (size < 0) {
           PyErr_SetString(PyExc_ValueError, "negative argument");
           return 0;
     }
-    consumed = size;
+    consumed = size; /* This is overwritten unless final is true. */
     decoded = PyUnicode_DecodeUTF16Stateful(data, size, errors,
 	&byteorder, final ? NULL : &consumed);
     if (decoded == NULL)
@@ -413,12 +410,11 @@
     if (!PyArg_ParseTuple(args, "t#|zii:utf_16_ex_decode",
 			  &data, &size, &errors, &byteorder, &final))
 	return NULL;
-    /* XXX Why is consumed initialized to size? mvl */
     if (size < 0) {
 	    PyErr_SetString(PyExc_ValueError, "negative argument");
 	    return 0;
     }
-    consumed = size;
+    consumed = size; /* This is overwritten unless final is true. */
     unicode = PyUnicode_DecodeUTF16Stateful(data, size, errors, &byteorder,
 					    final ? NULL : &consumed);
     if (unicode == NULL)


More information about the Python-checkins mailing list