[issue14465] xml.etree.ElementTree: add feature to prettify XML output
Alex Henderson added the comment: Proposed patch copied over from duplicate issue 17372. -- keywords: +patch nosy: +alex.henderson Added file: http://bugs.python.org/file31168/issue14465.patch ___ Python tracker <http://bugs.python.org/issue14465> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17840] base64_codec uses assert for runtime validity checks
Alex Henderson added the comment: OK, now raises ValueError on passing anything other than 'strict'. Note that for the incremental classes I've put checking in __init__ so that ValueError is raised when non-'strict' values are passed to the constructor, not when the incremental encode/decode methods are subsequently called. -- Added file: http://bugs.python.org/file30902/issue17840.patch ___ Python tracker <http://bugs.python.org/issue17840> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17372] provide pretty printer for xml.etree.ElementTree
Alex Henderson added the comment: One other design decision - currently it doesn't deal with the indentation of comments or processing instructions: it leaves them unindented. Should they be indented the same as other tags? -- ___ Python tracker <http://bugs.python.org/issue17372> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17840] base64_codec uses assert for runtime validity checks
Alex Henderson added the comment: Having discussed this with Ezio, I think the better option might be to raise ValueError instead - if someone is expecting to be able to silently recover from errors they won't be able to, and should find out about this sooner rather than later. I'll upload an updated patch shortly. -- ___ Python tracker <http://bugs.python.org/issue17840> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17372] provide pretty printer for xml.etree.ElementTree
Alex Henderson added the comment: I have attached a proposed patch. This makes some design decisions which I would like someone to review: a) To incorporate pretty-printing into the main write() method rather than adding a separate toprettyxml() method. Disadvantages: greater complexity of _serialize_xml(). Advantages: Reduced duplication of code, easy to add other pretty-printing (eg HTML) in the same way. b) Existing whitespace on the ends of existing text is mutated. Disadvantages: existing whitespace content may get changed. Advantages: Greater readability (which is the whole point), idempotence of pretty-printing. c) Not to add a trailing newline. I am undecided as to whether this is a bad idea or a good one, but am documenting it to ensure it gets visibility. Of these, I think b) is the only potentially controversial one, and notably its behaviour differs from minidom's toprettyxml. I think it's the right thing to do though; and for the cases where whitespace is important, perhaps we can respect the xml:space attribute when pretty-printing? http://www.w3.org/TR/xml/#sec-white-space If these design choices are deemed suitable I'm happy to update the patch to support pretty-printing HTML also. -- keywords: +patch nosy: +alex.henderson Added file: http://bugs.python.org/file30845/issue17372.patch ___ Python tracker <http://bugs.python.org/issue17372> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17840] base64_codec uses assert for runtime validity checks
Alex Henderson added the comment: I see that there is identical usage of "assert errors=='strict'" in a number of similar encodings modules: base64_codec.py bz2_codec.py hex_codec.py quopri_codec.py uu_codec.py zlib_codec.py The error handling mode is irrelevant for all these codecs, so the attached patch addresses them all (choosing to ignore the error mode and documenting this). -- keywords: +patch nosy: +alex.henderson Added file: http://bugs.python.org/file30814/issue17840.patch ___ Python tracker <http://bugs.python.org/issue17840> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com