mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #13782: streamline argument type-checking in ET.Element
append, extend and insert now consistently type-check their argument in both the C and Python implementations, and raise TypeError for non-Element argument. Added tests
This commit is contained in:
parent
42243c4dca
commit
396e8fcf36
4 changed files with 33 additions and 12 deletions
|
@ -281,14 +281,15 @@ Element Objects
|
|||
|
||||
.. method:: append(subelement)
|
||||
|
||||
Adds the element *subelement* to the end of this elements internal list
|
||||
of subelements.
|
||||
Adds the element *subelement* to the end of this element's internal list
|
||||
of subelements. Raises :exc:`TypeError` if *subelement* is not an
|
||||
:class:`Element`.
|
||||
|
||||
|
||||
.. method:: extend(subelements)
|
||||
|
||||
Appends *subelements* from a sequence object with zero or more elements.
|
||||
Raises :exc:`AssertionError` if a subelement is not a valid object.
|
||||
Raises :exc:`TypeError` if a subelement is not an :class:`Element`.
|
||||
|
||||
.. versionadded:: 3.2
|
||||
|
||||
|
@ -325,9 +326,10 @@ Element Objects
|
|||
Use method :meth:`Element.iter` instead.
|
||||
|
||||
|
||||
.. method:: insert(index, element)
|
||||
.. method:: insert(index, subelement)
|
||||
|
||||
Inserts a subelement at the given position in this element.
|
||||
Inserts *subelement* at the given position in this element. Raises
|
||||
:exc:`TypeError` if *subelement* is not an :class:`Element`.
|
||||
|
||||
|
||||
.. method:: iter(tag=None)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue