[pypy-svn] pypy default: Fix unicode % unicode_subclass

alex_gaynor commits-noreply at bitbucket.org
Thu Mar 10 15:35:53 CET 2011


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: 
Changeset: r42493:29c9daa92726
Date: 2011-03-10 09:35 -0500
http://bitbucket.org/pypy/pypy/changeset/29c9daa92726/

Log:	Fix unicode % unicode_subclass

diff --git a/pypy/objspace/std/test/test_unicodeobject.py b/pypy/objspace/std/test/test_unicodeobject.py
--- a/pypy/objspace/std/test/test_unicodeobject.py
+++ b/pypy/objspace/std/test/test_unicodeobject.py
@@ -833,3 +833,5 @@
         b = unicode(a)
         assert type(b) is unicode
         assert b == u'hello \u1234'
+
+        assert u'%s' % S(u'mar\xe7') == u'mar\xe7'
\ No newline at end of file

diff --git a/pypy/objspace/std/unicodetype.py b/pypy/objspace/std/unicodetype.py
--- a/pypy/objspace/std/unicodetype.py
+++ b/pypy/objspace/std/unicodetype.py
@@ -302,6 +302,8 @@
         # obscure workaround: for the next two lines see
         # test_unicode_conversion_with__str__
         if w_unicode_method is None:
+            if space.isinstance_w(w_obj, space.w_unicode):
+                return space.wrap(space.unicode_w(w_obj))
             w_unicode_method = space.lookup(w_obj, "__str__")
         if w_unicode_method is not None:
             w_res = space.get_and_call_function(w_unicode_method, w_obj)


More information about the Pypy-commit mailing list