mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-131938: Update exception message for Element.remove()
when an element is not found (#131972)
The exception message for `xml.etree.ElementTree.Element.remove` when an element is not found has been updated from "list.remove(x): x not in list" to "Element.remove(x): element not found".
This commit is contained in:
parent
df59226997
commit
04bc681e7c
4 changed files with 12 additions and 4 deletions
|
@ -267,7 +267,11 @@ class Element:
|
|||
|
||||
"""
|
||||
# assert iselement(element)
|
||||
self._children.remove(subelement)
|
||||
try:
|
||||
self._children.remove(subelement)
|
||||
except ValueError:
|
||||
# to align the error message with the C implementation
|
||||
raise ValueError("Element.remove(x): element not found") from None
|
||||
|
||||
def find(self, path, namespaces=None):
|
||||
"""Find first matching element by tag name or path.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue