mirror of
https://github.com/python/cpython.git
synced 2025-09-29 03:35:31 +00:00
Tests for new instance support in unicode().
This commit is contained in:
parent
3d476d73a9
commit
b6d78fcd9c
1 changed files with 15 additions and 0 deletions
|
@ -298,6 +298,21 @@ assert unicode('hello','utf-8') == u'hello'
|
||||||
assert unicode('hello','utf8') == u'hello'
|
assert unicode('hello','utf8') == u'hello'
|
||||||
assert unicode('hello','latin-1') == u'hello'
|
assert unicode('hello','latin-1') == u'hello'
|
||||||
|
|
||||||
|
class String:
|
||||||
|
x = ''
|
||||||
|
def __str__(self):
|
||||||
|
return self.x
|
||||||
|
|
||||||
|
o = String()
|
||||||
|
|
||||||
|
o.x = 'abc'
|
||||||
|
assert unicode(o) == u'abc'
|
||||||
|
assert str(o) == 'abc'
|
||||||
|
|
||||||
|
o.x = u'abc'
|
||||||
|
assert unicode(o) == u'abc'
|
||||||
|
assert str(o) == 'abc'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
u'Andr\202 x'.encode('ascii')
|
u'Andr\202 x'.encode('ascii')
|
||||||
u'Andr\202 x'.encode('ascii','strict')
|
u'Andr\202 x'.encode('ascii','strict')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue