summaryrefslogtreecommitdiffstats
path: root/Lib/xml
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-10-19 09:12:57 (GMT)
committerGitHub <noreply@github.com>2018-10-19 09:12:57 (GMT)
commitf081fd83032be48aefdb1bbcc38ab5deb03785d5 (patch)
tree9696b61136dbfe1bae2edbb249b25cd7143defea /Lib/xml
parent68def052dcd41313eff2bd9f269e22c5a941db4d (diff)
downloadcpython-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.py10
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):