[pypy-commit] pypy py3k: StringBuilder now build a (unicode) str.

amauryfa noreply at buildbot.pypy.org
Tue Feb 7 23:53:17 CET 2012


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3k
Changeset: r52210:108cb693adaa
Date: 2012-02-07 23:51 +0100
http://bitbucket.org/pypy/pypy/changeset/108cb693adaa/

Log:	StringBuilder now build a (unicode) str. BytesBuilder returns bytes.

diff --git a/pypy/module/__pypy__/__init__.py b/pypy/module/__pypy__/__init__.py
--- a/pypy/module/__pypy__/__init__.py
+++ b/pypy/module/__pypy__/__init__.py
@@ -9,7 +9,7 @@
 
     interpleveldefs = {
         "StringBuilder": "interp_builders.W_StringBuilder",
-        "UnicodeBuilder": "interp_builders.W_UnicodeBuilder",
+        "BytesBuilder": "interp_builders.W_BytesBuilder",
     }
 
 class Module(MixedModule):
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
@@ -64,5 +64,5 @@
     W_Builder.typedef.acceptable_as_base_class = False
     return W_Builder
 
-W_StringBuilder = create_builder("StringBuilder", str, StringBuilder)
-W_UnicodeBuilder = create_builder("UnicodeBuilder", unicode, UnicodeBuilder)
+W_StringBuilder = create_builder("StringBuilder", unicode, UnicodeBuilder)
+W_BytesBuilder = create_builder("BytesBuilder", str, StringBuilder)
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
@@ -6,8 +6,8 @@
         cls.space = gettestobjspace(usemodules=['__pypy__'])
 
     def test_simple(self):
-        from __pypy__.builders import UnicodeBuilder
-        b = UnicodeBuilder()
+        from __pypy__.builders import StringBuilder
+        b = StringBuilder()
         b.append("abc")
         b.append("123")
         b.append("1")
@@ -17,16 +17,16 @@
         raises(ValueError, b.append, "123")
 
     def test_preallocate(self):
-        from __pypy__.builders import UnicodeBuilder
-        b = UnicodeBuilder(10)
+        from __pypy__.builders import StringBuilder
+        b = StringBuilder(10)
         b.append("abc")
         b.append("123")
         s = b.build()
         assert s == "abc123"
 
     def test_append_slice(self):
-        from __pypy__.builders import UnicodeBuilder
-        b = UnicodeBuilder()
+        from __pypy__.builders import StringBuilder
+        b = StringBuilder()
         b.append_slice("abcdefgh", 2, 5)
         raises(ValueError, b.append_slice, "1", 2, 1)
         s = b.build()
@@ -34,8 +34,8 @@
         raises(ValueError, b.append_slice, "abc", 1, 2)
 
     def test_stringbuilder(self):
-        from __pypy__.builders import StringBuilder
-        b = StringBuilder()
+        from __pypy__.builders import BytesBuilder
+        b = BytesBuilder()
         b.append(b"abc")
         b.append(b"123")
         assert len(b) == 6


More information about the pypy-commit mailing list