homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: xml.etree.ElementTree.ElementTree.write - argument checking
Type: Stage:
Components: Documentation, XML Versions: Python 3.2
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, eli.bendersky, flox, patrick.vrijlandt
Priority: normal Keywords:

Created on 2012年01月19日 08:51 by patrick.vrijlandt, last changed 2022年04月11日 14:57 by admin. This issue is now closed.

Messages (2)
msg151612 - (view) Author: patrick vrijlandt (patrick.vrijlandt) Date: 2012年01月19日 08:51
(1) The docs say:
xml_declaration controls if an XML declaration should be added to the file. Use False for never, True for always, None for only if not US-ASCII or UTF-8 or Unicode (default is None). 
The method also accepts other values, like xml_declaration = "yes". This behavior should be documented, or raise a ValueError (up to effbot, I think)
(2) The docs say (in a note):
The encoding string included in XML output should conform to the appropriate standards. For example, "UTF-8" is valid, but "UTF8" is not. See http://www.w3.org/
But the method accepts both values, ("UTF-8" and "UTF8"). Since this will result in invalid xml, (but not invalid python) it should probably raise ValueError too.
(3) Open issue 9458 also refers to this method. It might be wise to raise ValueError if the encoding does not match the (mode of the) file target (binary or text).
msg165495 - (view) Author: Eli Bendersky (eli.bendersky) * (Python committer) Date: 2012年07月15日 03:35
About (1):
It's customary for Python to accept "truthful" values (like non-empty strings) as True. I see no harm in that. Strict type-checking to boolean True in each and every place is not necessary.
About (2):
Similarly, this isn't productive. ET may not know about all encodings underlying the system. The warning is clearly documented - it's up for the user to make sure it's valid.
History
Date User Action Args
2022年04月11日 14:57:25adminsetgithub: 58031
2012年07月15日 03:35:39eli.benderskysetstatus: open -> closed
resolution: wont fix
messages: + msg165495
2012年06月17日 09:30:40floxsetnosy: + flox
2012年06月17日 03:20:28eli.benderskysetnosy: + eli.bendersky
2012年01月19日 08:51:46patrick.vrijlandtcreate

AltStyle によって変換されたページ (->オリジナル) /