[Twisted-Python] xmlstream, parser bug & utf16 support

James Bunton james at delx.cjb.net
Mon Aug 30 15:45:30 MDT 2004


Hi all. I've started using the Jabber support in Twisted for building PyMSNt 
(a python MSN transport).

I seem to have found a bug in the XML parser. Firstly, it seems to raise an 
exception whenever an incoming packet has an attribute xml:lang="en"
For example..
<iq to="someaddr" type="get" xml:lang="en"/> will cause the parser to raise an 
exception.

Traceback (most recent call last):
   File "/usr/lib/python2.3/site-packages/twisted/internet/default.py", line 
526, in doSelect
     _logrun(selectable, _drdw, selectable, method, dict)
   File "/usr/lib/python2.3/site-packages/twisted/python/log.py", line 65, in 
callWithLogger
     callWithContext({"system": lp}, func, *args, **kw)
   File "/usr/lib/python2.3/site-packages/twisted/python/log.py", line 52, in 
callWithContext
     return context.call({ILogContext: newCtx}, func, *args, **kw)
   File "/usr/lib/python2.3/site-packages/twisted/python/context.py", line 43, 
in callWithContext
     return func(*args,**kw)
--- <exception caught here> ---
   File "/usr/lib/python2.3/site-packages/twisted/internet/default.py", line 
535, in _doReadOrWrite
     why = getattr(selectable, method)()
   File "/usr/lib/python2.3/site-packages/twisted/internet/tcp.py", line 255, 
in doRead
     return self.protocol.dataReceived(data)
   File 
"/usr/lib/python2.3/site-packages/twisted/protocols/xmlstream.py", line 158, 
in dataReceived
     self.stream.parse(buf)
   File "/usr/lib/python2.3/site-packages/twisted/xish/domish.py", line 593, 
in parse
     self.parser.Parse(buffer)
   File "/usr/lib/python2.3/site-packages/twisted/xish/domish.py", line 602, 
in _onStartElement
     attrs[k.split(" ")] = v


Any help on fixing this would be appreciated.


Also, does anybody have any clues on how to send utf16 characters in the 
xmlstream? I can't seem to work it out.

Thanks in advance..

---

James




More information about the Twisted-Python mailing list