You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Improve error message for Element.remove() #142306
Currently it imitates the error message for list.remove() and other collections: "Element.remove(x): element not found". But Element is not a general collection, so reasons for such error message are not applicable:
It can only contain other elements.
It may be useful to know what exact element was removed and from where. Their repr is limited, so it can be included in the error message.
I think I changed this one because I wanted to keep the existing messages but I don't remember. However, if we include the repr of an element, wouldn't it be then an issue if the element is very large?
Activity
pythongh-142306: Improve errors for Element.remove()
picnixz commentedon Dec 5, 2025
I think I changed this one because I wanted to keep the existing messages but I don't remember. However, if we include the repr of an element, wouldn't it be then an issue if the element is very large?
serhiy-storchaka commentedon Dec 5, 2025
No, because the size of the repr of the element is limited (*), it does not depend on its size. This is the difference from general collections.
*) If you don't create elements with unreasonably long names.
picnixz commentedon Dec 5, 2025
Oh then I guess it's fine!
serhiy-storchaka commentedon Dec 8, 2025
Ah, the current error message was changed not long ago (#131938). This makes changing it again easier.
gh-142306: Improve errors for Element.remove() (GH-142308)
pythongh-142306: Improve errors for Element.remove() (pythonGH-142308)
pythongh-142306: Improve errors for Element.remove() (pythonGH-142308)