New submission from Atamurad Hezretkuliyev <atamy...@gmail.com>:

Parsing "<test xmlns=''></test>" with minidom and converting back to string 
raises an exception.

>>> import xml.dom.minidom
>>> xml.dom.minidom.parseString("<test xmlns=''></test>").toxml()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xml/dom/minidom.py",
 line 45, in toxml
    return self.toprettyxml("", "", encoding)
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xml/dom/minidom.py",
 line 57, in toprettyxml
    self.writexml(writer, "", indent, newl, encoding)
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xml/dom/minidom.py",
 line 1749, in writexml
    node.writexml(writer, indent, addindent, newl)
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xml/dom/minidom.py",
 line 812, in writexml
    _write_data(writer, attrs[a_name].value)
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xml/dom/minidom.py",
 line 301, in _write_data
    data = data.replace("&", "&amp;").replace("<", "&lt;")
AttributeError: 'NoneType' object has no attribute 'replace'
>>> 

Ii am not familiar with the XML spec so I've no idea if ignoring or accepting 
empty namespace is the right thing to do. If someone advices me on how it 
should be handled, I'd like to write a patch.

----------
components: Library (Lib)
messages: 135867
nosy: atamyrat
priority: normal
severity: normal
status: open
title: Empty ('') xmlns attribute is not properly handled by xml.dom.minidom
type: behavior
versions: Python 2.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue12066>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to