Skip to content

xml.dom documents wrong exceptions for some methods #156635

Description

@serhiy-storchaka

Node.insertBefore(), Node.removeChild() and Node.replaceChild() are documented as raising ValueError if the node is not a child of this node, but they raise NotFoundErr, which is not a ValueError.

>>> import xml.dom.minidom
>>> doc = xml.dom.minidom.parseString('<r><c/></r>')
>>> doc.documentElement.removeChild(doc.createElement('x'))
xml.dom.NotFoundErr

Element.removeAttribute() is documented as raising NotFoundErr if there is no matching attribute, and Element.removeAttributeNS() is documented as raising nothing. Both raise NotFoundErr, so the two descriptions contradict each other. The DOM specifies that removing an absent attribute has no effect, so this is a deviation of xml.dom.minidom and should be documented in its documentation.

Affects all maintained versions.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes3.14bugs and security fixes3.15pre-release feature fixes, bugs and security fixes3.16new features, bugs and security fixesdocsDocumentation in the Doc dirtopic-XML

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions