Skip to content

Improve error message for Element.remove() #142306

Closed

Description

@serhiy-storchaka

Feature or enhancement

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:

  1. It can only contain other elements.
  2. 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.

Linked PRs

Activity

  1. added a commit that references this issue on Dec 5, 2025
  2. picnixz commented on Dec 5, 2025

    @picnixz
    Member

    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?

  3. serhiy-storchaka commented on Dec 5, 2025

    @serhiy-storchaka
    MemberAuthor

    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.

  4. picnixz commented on Dec 5, 2025

    @picnixz
    Member

    Oh then I guess it's fine!

  5. serhiy-storchaka commented on Dec 8, 2025

    @serhiy-storchaka
    MemberAuthor

    Ah, the current error message was changed not long ago (#131938). This makes changing it again easier.

  6. added a commit that references this issue on Jan 12, 2026
  7. added a commit that references this issue on Jan 12, 2026
  8. added a commit that references this issue on Feb 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions