Merge ssize_t branch.
diff --git a/Modules/_codecsmodule.c b/Modules/_codecsmodule.c
index 8b225c3..39b443b 100644
--- a/Modules/_codecsmodule.c
+++ b/Modules/_codecsmodule.c
@@ -35,6 +35,7 @@
 
    ------------------------------------------------------------------------ */
 
+#define PY_SSIZE_T_CLEAN
 #include "Python.h"
 
 /* --- Registry ----------------------------------------------------------- */
@@ -196,7 +197,7 @@
 {
     const char *errors = NULL;
     const char *data;
-    int size;
+    Py_ssize_t size;
 
     if (!PyArg_ParseTuple(args, "s#|z:escape_decode",
 			  &data, &size, &errors))
@@ -241,7 +242,7 @@
     PyObject *obj;
     const char *errors = NULL;
     const char *data;
-    int size;
+    Py_ssize_t size;
 
     if (!PyArg_ParseTuple(args, "O|z:unicode_internal_decode",
 			  &obj, &errors))
@@ -265,7 +266,7 @@
 	    PyObject *args)
 {
     const char *data;
-    int size;
+    Py_ssize_t size;
     const char *errors = NULL;
 
     if (!PyArg_ParseTuple(args, "t#|z:utf_7_decode",
@@ -281,15 +282,19 @@
 	    PyObject *args)
 {
     const char *data;
-    int size;
+    Py_ssize_t size;
     const char *errors = NULL;
     int final = 0;
-    int consumed;
+    Py_ssize_t consumed;
     PyObject *decoded = NULL;
 
     if (!PyArg_ParseTuple(args, "t#|zi:utf_8_decode",
 			  &data, &size, &errors, &final))
 	return NULL;
+    if (size < 0) {
+	    PyErr_SetString(PyExc_ValueError, "negative argument");
+	    return 0;
+    }
     consumed = size;
 	
     decoded = PyUnicode_DecodeUTF8Stateful(data, size, errors,
@@ -304,16 +309,21 @@
 	    PyObject *args)
 {
     const char *data;
-    int size;
+    Py_ssize_t size;
     const char *errors = NULL;
     int byteorder = 0;
     int final = 0;
-    int consumed;
+    Py_ssize_t consumed;
     PyObject *decoded;
 
     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;
     decoded = PyUnicode_DecodeUTF16Stateful(data, size, errors, &byteorder,
 					    final ? NULL : &consumed);
@@ -327,16 +337,22 @@
 		 PyObject *args)
 {
     const char *data;
-    int size;
+    Py_ssize_t size;
     const char *errors = NULL;
     int byteorder = -1;
     int final = 0;
-    int consumed;
+    Py_ssize_t consumed;
     PyObject *decoded = NULL;
 
     if (!PyArg_ParseTuple(args, "t#|zi:utf_16_le_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;
     decoded = PyUnicode_DecodeUTF16Stateful(data, size, errors,
 	&byteorder, final ? NULL : &consumed);
@@ -351,16 +367,21 @@
 		 PyObject *args)
 {
     const char *data;
-    int size;
+    Py_ssize_t size;
     const char *errors = NULL;
     int byteorder = 1;
     int final = 0;
-    int consumed;
+    Py_ssize_t consumed;
     PyObject *decoded = NULL;
 
     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;
     decoded = PyUnicode_DecodeUTF16Stateful(data, size, errors,
 	&byteorder, final ? NULL : &consumed);
@@ -382,17 +403,21 @@
 		 PyObject *args)
 {
     const char *data;
-    int size;
+    Py_ssize_t size;
     const char *errors = NULL;
     int byteorder = 0;
     PyObject *unicode, *tuple;
     int final = 0;
-    int consumed;
+    Py_ssize_t consumed;
 
     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;
     unicode = PyUnicode_DecodeUTF16Stateful(data, size, errors, &byteorder,
 					    final ? NULL : &consumed);
@@ -408,7 +433,7 @@
 		     PyObject *args)
 {
     const char *data;
-    int size;
+    Py_ssize_t size;
     const char *errors = NULL;
 
     if (!PyArg_ParseTuple(args, "t#|z:unicode_escape_decode",
@@ -424,7 +449,7 @@
 			PyObject *args)
 {
     const char *data;
-    int size;
+    Py_ssize_t size;
     const char *errors = NULL;
 
     if (!PyArg_ParseTuple(args, "t#|z:raw_unicode_escape_decode",
@@ -440,7 +465,7 @@
 	       PyObject *args)
 {
     const char *data;
-    int size;
+    Py_ssize_t size;
     const char *errors = NULL;
 
     if (!PyArg_ParseTuple(args, "t#|z:latin_1_decode",
@@ -456,7 +481,7 @@
 	     PyObject *args)
 {
     const char *data;
-    int size;
+    Py_ssize_t size;
     const char *errors = NULL;
 
     if (!PyArg_ParseTuple(args, "t#|z:ascii_decode",
@@ -472,7 +497,7 @@
 	       PyObject *args)
 {
     const char *data;
-    int size;
+    Py_ssize_t size;
     const char *errors = NULL;
     PyObject *mapping = NULL;
 
@@ -493,7 +518,7 @@
 	    PyObject *args)
 {
     const char *data;
-    int size;
+    Py_ssize_t size;
     const char *errors = NULL;
 
     if (!PyArg_ParseTuple(args, "t#|z:mbcs_decode",
@@ -513,7 +538,7 @@
 		  PyObject *args)
 {
     const char *data;
-    int size;
+    Py_ssize_t size;
     const char *errors = NULL;
 
     if (!PyArg_ParseTuple(args, "s#|z:readbuffer_encode",
@@ -529,7 +554,7 @@
 		  PyObject *args)
 {
     const char *data;
-    int size;
+    Py_ssize_t size;
     const char *errors = NULL;
 
     if (!PyArg_ParseTuple(args, "t#|z:charbuffer_encode",
@@ -547,7 +572,7 @@
     PyObject *obj;
     const char *errors = NULL;
     const char *data;
-    int size;
+    Py_ssize_t size;
 
     if (!PyArg_ParseTuple(args, "O|z:unicode_internal_encode",
 			  &obj, &errors))