Author: Carl Friedrich Bolz-Tereick <cfb...@gmx.de>
Branch: 
Changeset: r96350:bc9c696b8c95
Date: 2019-03-26 19:47 +0100
http://bitbucket.org/pypy/pypy/changeset/bc9c696b8c95/

Log:    use append_utf8 in W_UnicodeBuilder

diff --git a/pypy/module/__pypy__/interp_builders.py 
b/pypy/module/__pypy__/interp_builders.py
--- a/pypy/module/__pypy__/interp_builders.py
+++ b/pypy/module/__pypy__/interp_builders.py
@@ -65,9 +65,12 @@
         return W_UnicodeBuilder(space, 3 * size)
 
     def descr_append(self, space, w_s):
-        w_unicode = W_UnicodeObject.convert_arg_to_w_unicode(space, w_s)
-        s = space.utf8_w(w_unicode)
-        self.builder.append(s)
+        if isinstance(w_s, W_UnicodeObject):
+            self.builder.append_utf8(w_s._utf8, w_s._len())
+        else:
+            w_unicode = W_UnicodeObject.convert_arg_to_w_unicode(space, w_s)
+            s = space.utf8_w(w_unicode)
+            self.builder.append(s)
 
     @unwrap_spec(start=int, end=int)
     def descr_append_slice(self, space, w_s, start, end):
diff --git a/pypy/module/__pypy__/test/test_builders.py 
b/pypy/module/__pypy__/test/test_builders.py
--- a/pypy/module/__pypy__/test/test_builders.py
+++ b/pypy/module/__pypy__/test/test_builders.py
@@ -1,14 +1,16 @@
+# -*- encoding: utf-8 -*-
+
 class AppTestBuilders(object):
     spaceconfig = dict(usemodules=['__pypy__'])
 
     def test_simple(self):
         from __pypy__.builders import UnicodeBuilder
         b = UnicodeBuilder()
-        b.append(u"abc")
+        b.append(u"abc&#228;")
         b.append(u"123")
         b.append(u"1")
         s = b.build()
-        assert s == u"abc1231"
+        assert s == u"abc&#228;1231"
         assert type(s) is unicode
         assert b.build() == s
         b.append(u"123")
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to