mirror of
https://github.com/python/cpython.git
synced 2025-07-16 07:45:20 +00:00
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:
parent
ba7d95e215
commit
cf52c07843
5 changed files with 42 additions and 17 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue