[pypy-svn] r78431 - in pypy/branch/fast-forward/pypy/module/pyexpat: . test
afa at codespeak.net
afa at codespeak.net
Fri Oct 29 01:15:35 CEST 2010
Author: afa
Date: Fri Oct 29 01:15:34 2010
New Revision: 78431
Modified:
pypy/branch/fast-forward/pypy/module/pyexpat/interp_pyexpat.py
pypy/branch/fast-forward/pypy/module/pyexpat/test/test_parser.py
Log:
pyexpat: add parser.buffer_size
Modified: pypy/branch/fast-forward/pypy/module/pyexpat/interp_pyexpat.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/pyexpat/interp_pyexpat.py (original)
+++ pypy/branch/fast-forward/pypy/module/pyexpat/interp_pyexpat.py Fri Oct 29 01:15:34 2010
@@ -527,6 +527,16 @@
def descr_ErrorByteIndex(space, self):
return space.wrap(XML_GetErrorByteIndex(self.itself))
+ def get_buffer_size(space, self):
+ return space.wrap(self.buffer_size)
+ def set_buffer_size(space, self, w_value):
+ value = space.int_w(w_value)
+ if value <= 0:
+ raise OperationError(space.w_ValueError, space.wrap(
+ "buffer_size must be greater than zero"))
+ self.flush_character_buffer(space)
+ self.buffer_size = value
+
def get_buffer_text(space, self):
return space.wrap(self.buffer_w is not None)
def set_buffer_text(space, self, w_value):
@@ -561,6 +571,9 @@
ordered_attributes = bool_property('ordered_attributes', W_XMLParserType),
specified_attributes = bool_property('specified_attributes', W_XMLParserType),
intern = GetSetProperty(W_XMLParserType.get_intern, cls=W_XMLParserType),
+ buffer_size = GetSetProperty(W_XMLParserType.get_buffer_size,
+ W_XMLParserType.set_buffer_size,
+ cls=W_XMLParserType),
buffer_text = GetSetProperty(W_XMLParserType.get_buffer_text,
W_XMLParserType.set_buffer_text, cls=W_XMLParserType),
Modified: pypy/branch/fast-forward/pypy/module/pyexpat/test/test_parser.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/pyexpat/test/test_parser.py (original)
+++ pypy/branch/fast-forward/pypy/module/pyexpat/test/test_parser.py Fri Oct 29 01:15:34 2010
@@ -15,3 +15,9 @@
assert res == 1
raises(pyexpat.ExpatError, p.Parse, "3")
+
+ def test_set_buffersize(self):
+ import pyexpat
+ p = pyexpat.ParserCreate()
+ p.buffer_size = 150
+ assert p.buffer_size == 150
More information about the Pypy-commit
mailing list