[Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.159.2.1,2.159.2.2

Fred L. Drake python-dev@python.org
Thu, 10 Aug 2000 11:36:28 -0700


Update of /cvsroot/python/python/dist/src/Python
In directory slayer.i.sourceforge.net:/tmp/cvs-serv396/Python

Modified Files:
      Tag: cnri-16-start
	bltinmodule.c 
Log Message:

Merged patch 2.166->2.168 into the Python 1.6 branch; this patch changes
the unicode() built-in function to use the PyUnicode_FromEncodedObject()
API when appropriate.

This is needed to pass the regression tests.

Some unused variables in the unicode() implementation were removed as well.

This patch contains changes contributed by Marc-Andre Lemburg and Tim Peters.


Index: bltinmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v
retrieving revision 2.159.2.1
retrieving revision 2.159.2.2
diff -C2 -r2.159.2.1 -r2.159.2.2
*** bltinmodule.c	2000/08/03 16:50:35	2.159.2.1
--- bltinmodule.c	2000/08/10 18:36:25	2.159.2.2
***************
*** 136,141 ****
  {
          PyObject *v;
- 	const void *buffer;
- 	int len;
  	char *encoding = NULL;
  	char *errors = NULL;
--- 136,139 ----
***************
*** 143,160 ****
  	if ( !PyArg_ParseTuple(args, "O|ss:unicode", &v, &encoding, &errors) )
  	    return NULL;
! 	/* Special case: Unicode will stay Unicode */
! 	if (PyUnicode_Check(v)) {
! 	    if (encoding) {
! 		PyErr_SetString(PyExc_TypeError,
! 		  "unicode() does not support decoding of Unicode objects");
! 		return NULL;
! 	    }
! 	    Py_INCREF(v);
! 	    return v;
! 	}
! 	/* Read raw data and decode it */
! 	if (PyObject_AsReadBuffer(v, &buffer, &len))
! 	    return NULL;
! 	return PyUnicode_Decode((const char *)buffer, len, encoding, errors);
  }
  
--- 141,145 ----
  	if ( !PyArg_ParseTuple(args, "O|ss:unicode", &v, &encoding, &errors) )
  	    return NULL;
! 	return PyUnicode_FromEncodedObject(v, encoding, errors);
  }