[Twisted-Python] Minor patch to twisted.xish.domish

Aguido Horatio Davis horatio at computer.org
Thu Aug 12 21:19:21 EDT 2004


G'day,

I was playing with ElementStreams yesterday and I discovered that 
ExpatElementStream throws an IndexError if well-formed but 
ill-namespaced XML (well, the multistatus return body from a WebDAV 
request looked well-namespaced to _me_, but...) is fed to it for 
parsing.

Here's a patch against this morning's SVN tree that makes this 
behaviour go away.

Index: twisted/xish/domish.py
===================================================================
--- twisted/xish/domish.py      (revision 11309)
+++ twisted/xish/domish.py      (working copy)
@@ -617,7 +617,12 @@
                  del attrs[k]

          # Construct the new element
-        e = Element(qname, self.defaultNsStack[-1], attrs)
+       # AHD: make it not explode if no namespace on stack
+       try:
+           nsuri = self.defaultNsStack[-1]
+       except IndexError:
+           nsuri = None
+        e = Element(qname, nsuri, attrs)

          # Document already started
          if self.documentStarted == 1:

Cheers,

Horatio
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2369 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20040813/3e6dbcfe/attachment.bin 


More information about the Twisted-Python mailing list