[pypy-commit] pypy unicode-utf8-py3: rework logic of space.newtext() to special case None as CPython does
mattip
pypy.commits at gmail.com
Tue Oct 16 07:31:41 EDT 2018
Author: Matti Picus <matti.picus at gmail.com>
Branch: unicode-utf8-py3
Changeset: r95216:87307b6c75cd
Date: 2018-10-16 14:11 +0300
http://bitbucket.org/pypy/pypy/changeset/87307b6c75cd/
Log: rework logic of space.newtext() to special case None as CPython does
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
@@ -187,19 +187,18 @@
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, allow_surrogates = _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)
+ w_value = W_UnicodeObject.EMPTY
else:
- if space.isinstance_w(w_obj, space.w_unicode):
- raise oefmt(space.w_TypeError,
+ encoding, errors, allow_surrogates = _get_encoding_and_errors(space,
+ w_encoding, w_errors)
+ if 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_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
More information about the pypy-commit
mailing list