[issue24312] miniDOM._write_data() give a vague error message when the argument isn't of type str
New submission from Oz Tamir: In Python 3.3, 3.4 and on 3.6.0a0 (default:dfe62f685538) the following snippet: from xml.dom.minidom import getDOMImplementation doc = getDOMImplementation().createDocument(None, 'Issues Tracker', None) tracker = doc.documentElement new_issue = doc.createElement('issue') new_issue.setAttribute('id', 10) tracker.appendChild(new_issue) with open('file.xml', 'w') as f: ... doc.writexml(f, addindent='\t', newl='\n') will produce the following exception: [Traceback] AttributeError: 'int' object has no attribute 'replace' which I found to be vague and rather confusing. -- components: XML messages: 244283 nosy: oz.tamir priority: normal severity: normal status: open title: miniDOM._write_data() give a vague error message when the argument isn't of type str type: behavior versions: Python 3.3, Python 3.4, Python 3.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24312 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24312] miniDOM._write_data() give a vague error message when the argument isn't of type str
Oz Tamir added the comment: I created a patch that will raise a TypeError when _write_data() has recvived an argument that is not a str. I found this exception and the error message it provide to be more straight forward and helpful when encountering this error. -- keywords: +patch Added file: http://bugs.python.org/file39529/issue24312.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24312 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24312] miniDOM._write_data() give a vague error message when the argument isn't of type str
Eric V. Smith added the comment: As a rule, we don't put in checks like this. There are an untold number of places where such checks could be added. I suspect the new typing module will be a better way to catch these types of errors. Does the problem not occur with 3.5? -- nosy: +eric.smith ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24312 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24312] miniDOM._write_data() give a vague error message when the argument isn't of type str
Serhiy Storchaka added the comment: Agree with Eric. And the error message doesn't look lying. -- nosy: +serhiy.storchaka resolution: - rejected stage: - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24312 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com