Author: Manuel Jacob
Branch: refactor-str-types
Changeset: r65541:164d7408afeb
Date: 2013-07-22 20:18 +0200
http://bitbucket.org/pypy/pypy/changeset/164d7408afeb/

Log:    Reintroduce shortcut in unicode's __new__ method that was removed
        for some reason.

diff --git a/pypy/objspace/std/unicodeobject.py 
b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -358,12 +358,15 @@
     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'))
+        if is_precisely_unicode and space.is_w(w_unicodetype, space.w_unicode):
+            return w_obj
         w_value = w_obj
     else:
         if encoding is None and errors is None:
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to