New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AttributeError: 'NoneType' object has no attribute 'replace' #50012
Comments
[2009-04-15 17:53:10,198] ERROR:web-services:[19]: _write_data dunction should be something like this |
Have you tried this with xml.dom.minidom? |
Yes I am using xml.dom.minidom doc.toprettyxml(indent="\t").encode('utf-8') |
Here is the full traceback...
[2009-04-16 12:00:03,487] ERROR:web-services:[01]: Exception in call:
Traceback (most recent call last):
[2009-04-16 12:00:03,487] ERROR:web-services:[02]: File
"/home/hda/tiny/bzrtrunk/latest_released/server/bin/wizard/__init__.py",
line 74, in execute_cr
[2009-04-16 12:00:03,487] ERROR:web-services:[03]: action_res =
action(self, cr, uid, data, context)
[2009-04-16 12:00:03,488] ERROR:web-services:[04]: File
"/home/hda/tiny/bzrtrunk/latest_released/addons/base_module_record/wizard/base_module_save.py",
line 113, in _create_module
[2009-04-16 12:00:03,488] ERROR:web-services:[05]: res_xml =
mod.generate_xml(cr, uid)
[2009-04-16 12:00:03,488] ERROR:web-services:[06]: File
"/home/hda/tiny/bzrtrunk/latest_released/addons/base_module_record/base_module_record.py",
line 328, in generate_xml
[2009-04-16 12:00:03,488] ERROR:web-services:[07]: #
vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
[2009-04-16 12:00:03,488] ERROR:web-services:[08]: File
"/usr/lib/python2.5/site-packages/oldxml/_xmlplus/dom/minidom.py", line
47, in toxml
[2009-04-16 12:00:03,488] ERROR:web-services:[09]: return
self.toprettyxml("", "", encoding)
[2009-04-16 12:00:03,489] ERROR:web-services:[10]: File
"/usr/lib/python2.5/site-packages/oldxml/_xmlplus/dom/minidom.py", line
59, in toprettyxml
[2009-04-16 12:00:03,489] ERROR:web-services:[11]:
self.writexml(writer, "", indent, newl, encoding)
[2009-04-16 12:00:03,489] ERROR:web-services:[12]: File
"/usr/lib/python2.5/site-packages/oldxml/_xmlplus/dom/minidom.py", line
1746, in writexml
[2009-04-16 12:00:03,489] ERROR:web-services:[13]:
node.writexml(writer, indent, addindent, newl)
[2009-04-16 12:00:03,489] ERROR:web-services:[14]: File
"/usr/lib/python2.5/site-packages/oldxml/_xmlplus/dom/minidom.py", line
821, in writexml
[2009-04-16 12:00:03,490] ERROR:web-services:[15]:
node.writexml(writer,indent+addindent,addindent,newl)
[2009-04-16 12:00:03,490] ERROR:web-services:[16]: File
"/usr/lib/python2.5/site-packages/oldxml/_xmlplus/dom/minidom.py", line
821, in writexml
[2009-04-16 12:00:03,490] ERROR:web-services:[17]:
node.writexml(writer,indent+addindent,addindent,newl)
[2009-04-16 12:00:03,490] ERROR:web-services:[18]: File
"/usr/lib/python2.5/site-packages/oldxml/_xmlplus/dom/minidom.py", line
816, in writexml
[2009-04-16 12:00:03,491] ERROR:web-services:[19]:
_write_data(writer, attrs[a_name].value)
[2009-04-16 12:00:03,491] ERROR:web-services:[20]: File
"/usr/lib/python2.5/site-packages/oldxml/_xmlplus/dom/minidom.py", line
304, in _write_data
[2009-04-16 12:00:03,491] ERROR:web-services:[21]: data =
data.replace("&", "&").replace("<", "<")
[2009-04-16 12:00:03,491] ERROR:web-services:[22]: AttributeError:
'NoneType' object has no attribute 'replace' |
I have solved this error, |
I'm not able to reproduce the issue. Why don't you submit the unit test |
Please see this post. http://bytes.com/topic/python/answers/25245-minidom-questions |
This issue will not move unless somebody provides a unit test for it. |
Experiencing this issue too. It occurs when an xml element contains a blank xmlns attribute, e.g.: {{{ When toxml() is called on a minidom document with this attribute, the exception occurs. I am including a simple script that causes this crash. |
This following markup creates the mistake as described earlier in the comments <element xmlns=""> This markup doesn't <element xmlns="bla"> It returns <?xml version="1.0" ?><element xmlns="bla"> When using this markup <element bar=""> It outputs the right markup, <?xml version="1.0" ?><element bar=""> So the mistake occurs really when xmlns="". I have checked and the following markup is a conformant markup according to the XML specification so xmlns="" or bar="" are conformant on the root element. <element xmlns=""> XML Namespaces are defined in another specification. http://www.w3.org/TR/REC-xml-names/. In the section of Namespaces default http://www.w3.org/TR/REC-xml-names/#defaulting, The specification is clear. "The attribute value in a default namespace declaration MAY be empty. This has the same effect, within the scope of the declaration, of there being no default namespace." the proposed "if data:" earlier in the comment solves the issue. I have attached a unit testcase as required by Mark Lawrence (BreamoreBoy) |
Thanks for the test case, committed the fix and the new test in r85546. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: