[XML-SIG] Reconsidering NamespaceErr on '' and None

Alexandre Fayolle Alexandre.Fayolle@logilab.fr
Fri, 14 Dec 2001 16:49:31 +0100 (CET)


On Fri, 14 Dec 2001, Rich Salz wrote:

> I have an opensource SOAP toolkit that runs on several DOM's: PyXML 0.6,
> the planned 0.7, and the FourThought 4dom and cDomlette.  I wrote my own
> accessors, like this:
>     _find_attr = lambda E, attr: \
>         E.getAttributeNS(None, attr) or E.getAttributeNS("", attr)
> 
> This now breaks, raising 
>   File "/usr/lib/python2.1/site-packages/_xmlplus/dom/NamedNodeMap.py",
> line 81, in getNamedItemNS
>     raise NamespaceErr("Use None instead of '' for empty namespace")
> 
> I think this is a mistake as it makes it difficult to write portable
> code.

A better way is to use a symbolic constant for empty namespace. If
xml.dom.EMPTY_NAMESPACE exists, you can use it safely, if not, you can
define it to ''

However, if the general opinion on the list is that raising an exception
in 0.7 is too early, I'll remove raise statement and silently convert the
'' to None.

However, adding the exception in 0.8 will break things in exactly the same
way as it did until now. A better way ofr handling the migration would be
using warnings, but this won't work with python < 2.1, I think.

Alexandre Fayolle
-- 
LOGILAB, Paris (France).
http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org
Narval, the first software agent available as free software (GPL).