[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pypy-svn
Subject:    [pypy-commit] pypy py3.5: hg merge default
From:       amauryfa <pypy.commits () gmail ! com>
Date:       2018-12-30 2:22:10
Message-ID: 5c282bd2.1c69fb81.ee85b.37b6 () mx ! google ! com
[Download RAW message or body]

Author: Amaury Forgeot d'Arc <amauryfa@gmail.com>
Branch: py3.5
Changeset: r95535:f81df27a6bf7
Date: 2018-12-30 03:20 +0100
http://bitbucket.org/pypy/pypy/changeset/f81df27a6bf7/

Log:	hg merge default

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
@@ -1105,9 +1105,8 @@
         assert type(str(z)) is str
         assert str(z) == u'foobaz'
         #
-        # two completely corner cases where we differ from CPython:
-        #assert unicode(encoding='supposedly_the_encoding') == u''
-        #assert unicode(errors='supposedly_the_error') == u''
+        assert str(encoding='supposedly_the_encoding') == u''
+        assert str(errors='supposedly_the_error') == u''
         e = raises(TypeError, str, u'', 'supposedly_the_encoding')
         assert str(e.value) == 'decoding str is not supported'
         e = raises(TypeError, str, u'', errors='supposedly_the_error')
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
@@ -223,20 +223,18 @@
     @staticmethod
     def descr_new(space, w_unicodetype, w_object=None, w_encoding=None,
                   w_errors=None):
-        if w_object is None:
-            w_object = W_UnicodeObject.EMPTY
-        w_obj = w_object
-
         encoding, errors = _get_encoding_and_errors(space, w_encoding,
                                                     w_errors)
-        if encoding is None and errors is None:
-            # this is very quick if w_obj is already a w_unicode
-            w_value = unicode_from_object(space, w_obj)
+        if w_object is None:
+            w_value = W_UnicodeObject.EMPTY
+        elif encoding is None and errors is None:
+            # this is very quick if w_object is already a w_unicode
+            w_value = unicode_from_object(space, w_object)
         else:
-            if space.isinstance_w(w_obj, space.w_unicode):
+            if space.isinstance_w(w_object, space.w_unicode):
                 raise oefmt(space.w_TypeError,
                             "decoding str is not supported")
-            w_value = unicode_from_encoded_object(space, w_obj,
+            w_value = unicode_from_encoded_object(space, w_object,
                                                   encoding, errors)
         if space.is_w(w_unicodetype, space.w_unicode):
             return w_value
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic