Closed
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-XMLtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
| BPO | 28237 |
|---|---|
| Nosy | @scoder, @py-user |
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:
assignee = None
closed_at = <Date 2019-09-10.16:09:54.847>
created_at = <Date 2016-09-21.12:19:15.151>
labels = ['expert-XML', 'type-bug', 'library']
title = 'In xml.etree.ElementTree bytes tag or attributes raises on serialization'
updated_at = <Date 2019-09-10.16:09:54.834>
user = 'https://github.com/py-user'bugs.python.org fields:
activity = <Date 2019-09-10.16:09:54.834>
actor = 'scoder'
assignee = 'none'
closed = True
closed_date = <Date 2019-09-10.16:09:54.847>
closer = 'scoder'
components = ['Library (Lib)', 'XML']
creation = <Date 2016-09-21.12:19:15.151>
creator = 'py.user'
dependencies = []
files = []
hgrepos = []
issue_num = 28237
keywords = []
message_count = 2.0
messages = ['277128', '351721']
nosy_count = 2.0
nosy_names = ['scoder', 'py.user']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue28237'
versions = ['Python 3.6']Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-XMLtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
py-user commentedon Sep 21, 2016
https://docs.python.org/3/library/xml.etree.elementtree.html#xml.etree.ElementTree.Element
"The element name, attribute names, and attribute values can be either bytestrings or Unicode strings."
The element name, attribute names, and attribute values can have bytes type, but they can't be serialized:
Also attribute name can be serialized, but it holds the letter "b" and single quotes:
And same try with site package lxml works fine for all cases because it converts bytes to unicode strings right away:
scoder commentedon Sep 10, 2019
Arguably, writing out "b'x'" as attribute name instead of raising an exception isn't ideal. However, OTOH, I think it's reasonable to accept anything that is serialisable as a string, not just strings. That makes it difficult to draw a line.
In any case, it's ok for ElementTree to not allow bytes in general.
I'll close this issue, because I don't think it's worth being called a bug.