]> granicus.if.org Git - python/commit
The string formatting code has a test to switch to Unicode when %s
authorGuido van Rossum <guido@python.org>
Wed, 9 Oct 2002 19:07:53 +0000 (19:07 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 9 Oct 2002 19:07:53 +0000 (19:07 +0000)
commitb00c07f038b3fdc567eaf7ae3d6f5006dd66a5dd
treec96e7f2b62b7384009c14a4613ce0022f24e3324
parent06e2a5e05275f814ec179d0c1dc2980cd237a521
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.

Also fixed an error message -- %s argument has non-string str()
doesn't make sense for %r, so the error message now differentiates
between %s and %r.
Objects/stringobject.c