Author: Philip Jenvey <[email protected]>
Branch: stdlib-2.7.11
Changeset: r83236:a3c0a3f30615
Date: 2016-03-21 18:25 -0700
http://bitbucket.org/pypy/pypy/changeset/a3c0a3f30615/
Log: implement a getter for parser's namespace_prefixes
diff --git a/pypy/module/pyexpat/interp_pyexpat.py
b/pypy/module/pyexpat/interp_pyexpat.py
--- a/pypy/module/pyexpat/interp_pyexpat.py
+++ b/pypy/module/pyexpat/interp_pyexpat.py
@@ -429,6 +429,7 @@
self.returns_unicode = True
self.ordered_attributes = False
self.specified_attributes = False
+ self.ns_prefixes = False
self.handlers = [None] * NB_HANDLERS
@@ -620,12 +621,12 @@
def get_namespace_prefixes(self, space):
- raise OperationError(space.w_AttributeError,
- space.wrap("not implemented: reading namespace_prefixes"))
+ return space.wrap(self.ns_prefixes)
@unwrap_spec(value=int)
def set_namespace_prefixes(self, space, value):
- XML_SetReturnNSTriplet(self.itself, bool(value))
+ self.ns_prefixes = bool(value)
+ XML_SetReturnNSTriplet(self.itself, self.ns_prefixes)
# Parse methods
diff --git a/pypy/module/pyexpat/test/test_parser.py
b/pypy/module/pyexpat/test/test_parser.py
--- a/pypy/module/pyexpat/test/test_parser.py
+++ b/pypy/module/pyexpat/test/test_parser.py
@@ -20,6 +20,15 @@
pyexpat.ExpatError("error")
+ def test_attributes(self):
+ import pyexpat
+ p = pyexpat.ParserCreate()
+ assert p.buffer_text is False
+ assert p.namespace_prefixes is False
+ assert p.returns_unicode is True
+ assert p.ordered_attributes is False
+ assert p.specified_attributes is False
+
def test_version(self):
import pyexpat
assert isinstance(pyexpat.__version__, str)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit