[Python-checkins] CVS: python/dist/src/Objects object.c,2.70.2.3,2.70.2.4

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


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

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

Merged patch 2.79->2.80 into the Python 1.6 branch; this patch causes
str() and repr() to convert Unicode strings returned by __str__() and
__repr__() methods to 8-bits strings in the default encoding.

This is needed to pass the regression tests.

Patch contributed by Marc-Andre Lemburg.


Index: object.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v
retrieving revision 2.70.2.3
retrieving revision 2.70.2.4
diff -C2 -r2.70.2.3 -r2.70.2.4
*** object.c	2000/08/07 19:11:41	2.70.2.3
--- object.c	2000/08/10 18:32:05	2.70.2.4
***************
*** 227,230 ****
--- 227,238 ----
  		if (res == NULL)
  			return NULL;
+ 		if (PyUnicode_Check(res)) {
+ 			PyObject* str;
+ 			str = PyUnicode_AsEncodedString(res, NULL, NULL);
+ 			if (str) {
+ 				Py_DECREF(res);
+ 				res = str;
+ 			}
+ 		}
  		if (!PyString_Check(res)) {
  			PyErr_Format(PyExc_TypeError,
***************
*** 264,267 ****
--- 272,283 ----
  	if (res == NULL)
  		return NULL;
+     if (PyUnicode_Check(res)) {
+         PyObject* str;
+         str = PyUnicode_AsEncodedString(res, NULL, NULL);
+         if (str) {
+             Py_DECREF(res);
+             res = str;
+         }
+     }
  	if (!PyString_Check(res)) {
  		PyErr_Format(PyExc_TypeError,