[XML-SIG] Empty string namespace - to bug or not to bug?

Fred L. Drake, Jr. fdrake at acm.org
Mon Oct 13 12:27:02 EDT 2003

Andrew Clover writes:
 > IMO yes, but the bug occurs before doc.toxml. After the
 > parseString call, doc.documentElement.attributes.item(0).value
 > evaluates to None instead of '' (and it is this that causes the
 > later exception).

Yep, that's the bug.

 > I suspect this code in expatbuilder.py, line 764:
 >   d = a.childNodes[0].__dict__
 >   d['data'] = d['nodeValue'] = uri
 >   d = a.__dict__
 >   d['value'] = d['nodeValue'] = uri

As well you should!  ;-)

 > Adding:
 >   if uri is None:
 >     uri= ''
 > immediately preceding this code seems to fix the problem, though
 > I haven't investigated whether this is the best way of doing it.
 > Add to bug tracker [Y|N]?

No.  I've just checked in the fix, so there's no need.

Thomas:  You're right that None should be used for the namespaceURI
for the empty namespace, but it shouldn't be used as the value for the
attribute.  The attribute value itself is still the empty string.


Fred L. Drake, Jr.  <fdrake at acm.org>
PythonLabs at Zope Corporation

More information about the XML-SIG mailing list