[XML-SIG] Reconsidering NamespaceErr on '' and None
Fred L. Drake, Jr.
fdrake@acm.org
Fri, 14 Dec 2001 11:28:42 -0500
Rich Salz writes:
> If PyXML 0.7 silently converts '' to None, then I can go back to
> _find_attr = lambda E, attr: E.getAttributeNS(None, attr) or \
> E.getAttributeNS('', attr)
> which has a performance hit if the attribute is not found.
Here's an idea: the exception should be raised when attempting to
set an attribute with a namespace URI of '', but queries could allow
either:
def getAttributeNS(self, namespaceURI, localName):
namespaceURI = namespaceURI or None
...
This isn't perfect, but would probably avoid most problems with
client code that uses ''.
-Fred
--
Fred L. Drake, Jr. <fdrake at acm.org>
PythonLabs at Zope Corporation