[docs] (take 2) Python 3.1.2 xml.sax doc error, or bug, or error by the operator...
Ryan, Thomas
thomas.ryan at hp.com
Wed Nov 24 08:47:06 CET 2010
Fixed typos...(sorry -, accidentally sent a draft, back now)
----
Thanks in advance for your help.
http://docs.python.org/py3k/library/xml.sax.html
The description
xml.sax.parseString(string, handler[, error_handler])
Similar to parse(), but parses from a buffer string received as a parameter.
seems incorrect, or misleading. Is the term "buffer" significant? Only "string" is italicized.
Do I need a PyBuff from C/C++ (of some sort)?
I am not a Python expert, but here is my snippet that fails.
I did Google around for help but the examples I found were all python 2.x.
Those refer to set "self" content handlers, but I could not get those to work with a string/bytes either.
It seems that in Python 3 someone moved the internal variable access to a parameterized input.
Ok with me, to further hide internal values, but something seems broken.
BTW - Sees to work fine with files & streams.
Code -
import xml.sax
class myHandler(xml.sax.ContentHandler) :
pass
m = myHandler()
## both of the next two cals throw the same exception (consistency is not surprising, but was worth checking, I guess)
## I assume the handler parameter is OK
xml.sax.parseString("hello", m)
##xml.sax.parseString(b"<abc><\abc>".decode("utf8"), m)
Traceback (most recent call last):
File " xmlsad.py", line 10, in <module>
xml.sax.parseString("hello", m)
File "C:\Python31\lib\xml\sax\__init__.py", line 45, in parseString
inpsrc.setByteStream(BytesIO(string))
TypeError: 'str' does not support the buffer interface
Any ideas regarding to expand the documentation re the buffer interface (Pybuff?), or to adjust the xml.sax.parseString() code?
Thanks,
Tom Ryan
More information about the docs
mailing list