Carl Friedrich Bolz  committed 666a488 Merge


  • Participants
  • Parent commits b1419a3, e2f91e3

Comments (0)

Files changed (2)

File pypy/objspace/std/test/

         w_str ='abcd')
         assert == list(u"abcd")
+    def test_new_shortcut(self):
+        space =
+        w_uni ='abcd')
+        w_new = space.call_method(
+                space.w_unicode, "__new__", space.w_unicode, w_uni)
+        assert w_new is w_uni
 class AppTestUnicodeStringStdOnly:
     def test_compares(self):

File pypy/objspace/std/

     encoding, errors = _get_encoding_and_errors(space, w_encoding, w_errors)
     # convoluted logic for the case when unicode subclass has a __unicode__
     # method, we need to call this method
-    if (space.is_w(space.type(w_obj), space.w_unicode) or
+    is_precisely_unicode = space.is_w(space.type(w_obj), space.w_unicode)
+    if (is_precisely_unicode or
         (space.isinstance_w(w_obj, space.w_unicode) and
          space.findattr(w_obj, space.wrap('__unicode__')) is None)):
         if encoding is not None or errors is not None:
             raise OperationError(space.w_TypeError,
                                  space.wrap('decoding Unicode is not supported'))
         w_value = w_obj
+        if is_precisely_unicode and space.is_w(w_unicodetype, space.w_unicode):
+            return w_value
         if encoding is None and errors is None:
             w_value = unicode_from_object(space, w_obj)