diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2018-10-19 09:12:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-19 09:12:57 (GMT) |
commit | f081fd83032be48aefdb1bbcc38ab5deb03785d5 (patch) | |
tree | 9696b61136dbfe1bae2edbb249b25cd7143defea /Lib/xml | |
parent | 68def052dcd41313eff2bd9f269e22c5a941db4d (diff) | |
download | cpython-f081fd83032be48aefdb1bbcc38ab5deb03785d5.zip cpython-f081fd83032be48aefdb1bbcc38ab5deb03785d5.tar.gz cpython-f081fd83032be48aefdb1bbcc38ab5deb03785d5.tar.bz2 |
bpo-35013: Add more type checks for children of Element. (GH-9944)
It is now guarantied that children of xml.etree.ElementTree.Element
are Elements (at least in C implementation). Previously methods
__setitem__(), __setstate__() and __deepcopy__() could be used for
adding non-Element children.
Diffstat (limited to 'Lib/xml')
-rw-r--r-- | Lib/xml/etree/ElementTree.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py index 371b371..85586d0 100644 --- a/Lib/xml/etree/ElementTree.py +++ b/Lib/xml/etree/ElementTree.py @@ -217,11 +217,11 @@ class Element: return self._children[index] def __setitem__(self, index, element): - # if isinstance(index, slice): - # for elt in element: - # assert iselement(elt) - # else: - # assert iselement(element) + if isinstance(index, slice): + for elt in element: + self._assert_is_element(elt) + else: + self._assert_is_element(element) self._children[index] = element def __delitem__(self, index): |