[Python-checkins] CVS: python/dist/src/Modules _codecsmodule.c,2.9,2.10

M.-A. Lemburg lemburg@users.sourceforge.net
Thu, 20 Sep 2001 03:35:48 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv17012/Modules

Modified Files:
	_codecsmodule.c 
Log Message:
Patch #435971: UTF-7 codec by Brian Quinlan.



Index: _codecsmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_codecsmodule.c,v
retrieving revision 2.9
retrieving revision 2.10
diff -C2 -d -r2.9 -r2.10
*** _codecsmodule.c	2001/08/17 18:39:25	2.9
--- _codecsmodule.c	2001/09/20 10:35:46	2.10
***************
*** 125,128 ****
--- 125,144 ----
  
  static PyObject *
+ utf_7_decode(PyObject *self,
+ 	    PyObject *args)
+ {
+     const char *data;
+     int size;
+     const char *errors = NULL;
+     
+     if (!PyArg_ParseTuple(args, "t#|z:utf_7_decode",
+ 			  &data, &size, &errors))
+ 	return NULL;
+ 
+     return codec_tuple(PyUnicode_DecodeUTF7(data, size, errors),
+ 		       size);
+ }
+ 
+ static PyObject *
  utf_8_decode(PyObject *self,
  	    PyObject *args)
***************
*** 383,386 ****
--- 399,426 ----
  
  static PyObject *
+ utf_7_encode(PyObject *self,
+ 	    PyObject *args)
+ {
+     PyObject *str, *v;
+     const char *errors = NULL;
+ 
+     if (!PyArg_ParseTuple(args, "O|z:utf_7_encode",
+ 			  &str, &errors))
+ 	return NULL;
+ 
+     str = PyUnicode_FromObject(str);
+     if (str == NULL)
+ 	return NULL;
+     v = codec_tuple(PyUnicode_EncodeUTF7(PyUnicode_AS_UNICODE(str),
+ 					 PyUnicode_GET_SIZE(str),
+                      0,
+                      0,
+ 					 errors),
+ 		    PyUnicode_GET_SIZE(str));
+     Py_DECREF(str);
+     return v;
+ }
+ 
+ static PyObject *
  utf_8_encode(PyObject *self,
  	    PyObject *args)
***************
*** 633,636 ****
--- 673,678 ----
      {"utf_8_encode",		utf_8_encode,			1},
      {"utf_8_decode",		utf_8_decode,			1},
+     {"utf_7_encode",		utf_7_encode,			1},
+     {"utf_7_decode",		utf_7_decode,			1},
      {"utf_16_encode",		utf_16_encode,			1},
      {"utf_16_le_encode",	utf_16_le_encode,		1},