Author: Maciej Fijalkowski <fij...@gmail.com> Branch: Changeset: r47840:f4baf68db210 Date: 2011-10-06 04:05 +0200 http://bitbucket.org/pypy/pypy/changeset/f4baf68db210/
Log: merge default 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 @@ -40,6 +40,12 @@ self.builder = None return w_s + def descr_len(self, space): + if self.builder is None: + raise OperationError(space.w_ValueError, + space.wrap('no lenght of built builder')) + return space.wrap(self.builder.getlength()) + W_Builder.__name__ = "W_%s" % name W_Builder.typedef = TypeDef(name, __new__ = interp2app(func_with_new_name( @@ -48,6 +54,7 @@ append = interp2app(W_Builder.descr_append), append_slice = interp2app(W_Builder.descr_append_slice), build = interp2app(W_Builder.descr_build), + __len__ = interp2app(W_Builder.descr_len), ) W_Builder.typedef.acceptable_as_base_class = False return W_Builder 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 @@ -38,7 +38,9 @@ b = StringBuilder() b.append("abc") b.append("123") + assert len(b) == 6 b.append("you and me") s = b.build() + raises(ValueError, len, b) assert s == "abc123you and me" - raises(ValueError, b.build) \ No newline at end of file + raises(ValueError, b.build) _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit