[Python-checkins] python/dist/src/Objects stringobject.c,2.147.6.9,2.147.6.10

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
Thu, 10 Oct 2002 17:09:54 -0700


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

Modified Files:
      Tag: release22-maint
	stringobject.c 
Log Message:
Backport the relevant part of 2.192:

The string formatting code has a test to switch to Unicode when %s
sees a Unicode argument.  Unfortunately this test was also executed
for %r, because %s and %r share almost all of their code.  This meant
that, if u is a unicode object while repr(u) is an 8-bit string
containing ASCII characters, '%r' % u is a *unicode* string containing
only ASCII characters!

Fixed by executing the test only for %s.


Index: stringobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v
retrieving revision 2.147.6.9
retrieving revision 2.147.6.10
diff -C2 -d -r2.147.6.9 -r2.147.6.10
*** stringobject.c	23 Sep 2002 21:17:27 -0000	2.147.6.9
--- stringobject.c	11 Oct 2002 00:09:51 -0000	2.147.6.10
***************
*** 3503,3507 ****
  				break;
  			case 's':
-   			case 'r':
  #ifdef Py_USING_UNICODE
  				if (PyUnicode_Check(v)) {
--- 3503,3506 ----
***************
*** 3511,3514 ****
--- 3510,3515 ----
  				}
  #endif
+ 				/* Fall through */
+   			case 'r':
  				if (c == 's')
  					temp = PyObject_Str(v);