Change the %s format specifier for str objects so that it returns a

unicode instance if the argument is not an instance of basestring and
calling __str__ on the argument returns a unicode instance.
This commit is contained in:
Neil Schemenauer 2005-08-12 17:34:58 +00:00
parent ba7d95e215
commit cf52c07843
5 changed files with 42 additions and 17 deletions

View file

@ -388,6 +388,10 @@ class UnicodeTest(
self.assertEqual('%i %*.*s' % (10, 5,3,u'abc',), u'10 abc')
self.assertEqual('%i%s %*.*s' % (10, 3, 5, 3, u'abc',), u'103 abc')
self.assertEqual('%c' % u'a', u'a')
class Wrapper:
def __str__(self):
return u'\u1234'
self.assertEqual('%s' % Wrapper(), u'\u1234')
def test_constructor(self):
# unicode(obj) tests (this maps to PyObject_Unicode() at C level)