diff options
author | Marc-André Lemburg <mal@egenix.com> | 2001-09-20 12:53:16 (GMT) |
---|---|---|
committer | Marc-André Lemburg <mal@egenix.com> | 2001-09-20 12:53:16 (GMT) |
commit | 6871f6ac57baca19facf5b49846b101c60ef3334 (patch) | |
tree | 033ba35ab876fc889c2691704e3d7e651ae57fa5 /Lib/test/test_unicode.py | |
parent | c60e6f777114f43c64f1b83f9ad2b6e4efd220e7 (diff) | |
download | cpython-6871f6ac57baca19facf5b49846b101c60ef3334.zip cpython-6871f6ac57baca19facf5b49846b101c60ef3334.tar.gz cpython-6871f6ac57baca19facf5b49846b101c60ef3334.tar.bz2 |
Implement the changes proposed in patch #413333. unicode(obj) now
works just like str(obj) in that it tries __str__/tp_str on the object
in case it finds that the object is not a string or buffer.
Diffstat (limited to 'Lib/test/test_unicode.py')
-rw-r--r-- | Lib/test/test_unicode.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py index d57328d..d508bef 100644 --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -429,6 +429,7 @@ verify(unicode('hello','utf-8') == u'hello') verify(unicode('hello','utf8') == u'hello') verify(unicode('hello','latin-1') == u'hello') +# Compatibility to str(): class String: x = '' def __str__(self): @@ -444,6 +445,10 @@ o.x = u'abc' verify(unicode(o) == u'abc') verify(str(o) == 'abc') +for obj in (123, 123.45, 123L): + verify(unicode(obj) == unicode(str(obj))) + +# Error handling try: u'Andr\202 x'.encode('ascii') u'Andr\202 x'.encode('ascii','strict') |