Commits

Amaury Forgeot d'Arc committed 108cb69

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

Comments (0)

Files changed (3)

pypy/module/__pypy__/__init__.py

 
     interpleveldefs = {
         "StringBuilder": "interp_builders.W_StringBuilder",
-        "UnicodeBuilder": "interp_builders.W_UnicodeBuilder",
+        "BytesBuilder": "interp_builders.W_BytesBuilder",
     }
 
 class Module(MixedModule):

pypy/module/__pypy__/interp_builders.py

     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)

pypy/module/__pypy__/test/test_builders.py

         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")
         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()
         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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.