[Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.110,2.111

Tim Peters tim_one@users.sourceforge.net
Mon, 10 Sep 2001 20:07:40 -0700


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

Modified Files:
	unicodeobject.c 
Log Message:
Possibly the end of SF [#460020] bug or feature: unicode() and subclasses.
Changed unicode(i) to return a true Unicode object when i is an instance of
a unicode subclass.  Added PyUnicode_CheckExact macro.


Index: unicodeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v
retrieving revision 2.110
retrieving revision 2.111
diff -C2 -d -r2.110 -r2.111
*** unicodeobject.c	2001/09/11 02:00:50	2.110
--- unicodeobject.c	2001/09/11 03:07:38	2.111
***************
*** 426,435 ****
      if (PyUnicode_Check(obj)) {
  	if (encoding) {
! 	    PyErr_SetString(PyExc_TypeError,
  			    "decoding Unicode is not supported");
! 	    return NULL;
  	}
! 	Py_INCREF(obj);
! 	v = obj;
  	goto done;
      }
--- 426,443 ----
      if (PyUnicode_Check(obj)) {
  	if (encoding) {
!             PyErr_SetString(PyExc_TypeError,
  			    "decoding Unicode is not supported");
!             return NULL;
  	}
!         if (PyUnicode_CheckExact(obj)) {
! 	    Py_INCREF(obj);
!             v = obj;
! 	}
!         else {
!             /* For a subclass of unicode, return a true unicode object
!                with the same string value. */
!             v = PyUnicode_FromUnicode(PyUnicode_AS_UNICODE(obj),
!                                       PyUnicode_GET_SIZE(obj));
!         }
  	goto done;
      }