Skip to content

Commit 00347e2

Browse files
[3.15] gh-156635: Fix the exceptions in the xml.dom documentation (GH-156636) (#156637)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
1 parent 9b7ba24 commit 00347e2

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

Doc/library/xml.dom.minidom.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,11 @@ rules apply:
264264
* :attr:`~xml.dom.Document.strictErrorChecking` and
265265
:attr:`~xml.dom.Attr.specified` are always ``False``.
266266

267+
* :meth:`~xml.dom.Element.removeAttribute` and
268+
:meth:`~xml.dom.Element.removeAttributeNS` raise
269+
:exc:`~xml.dom.NotFoundErr` if there is no matching attribute,
270+
while the DOM specifies that this has no effect.
271+
267272
The following interfaces have no implementation in :mod:`!xml.dom.minidom`:
268273

269274
* :class:`DOMTimeStamp`

Doc/library/xml.dom.rst

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -461,23 +461,23 @@ for each node type are:
461461
.. method:: Node.insertBefore(newChild, refChild)
462462

463463
Insert a new child node before an existing child. It must be the case that
464-
*refChild* is a child of this node; if not, :exc:`ValueError` is raised.
464+
*refChild* is a child of this node; if not, :exc:`NotFoundErr` is raised.
465465
*newChild* is returned. If *refChild* is ``None``, it inserts *newChild* at the
466466
end of the children's list.
467467

468468

469469
.. method:: Node.removeChild(oldChild)
470470

471471
Remove a child node. *oldChild* must be a child of this node; if not,
472-
:exc:`ValueError` is raised. *oldChild* is returned on success. If *oldChild*
472+
:exc:`NotFoundErr` is raised. *oldChild* is returned on success. If *oldChild*
473473
will not be used further, its :meth:`~xml.dom.minidom.Node.unlink` method
474474
should be called.
475475

476476

477477
.. method:: Node.replaceChild(newChild, oldChild)
478478

479479
Replace an existing node with a new node. It must be the case that *oldChild*
480-
is a child of this node; if not, :exc:`ValueError` is raised.
480+
is a child of this node; if not, :exc:`NotFoundErr` is raised.
481481

482482

483483
.. method:: Node.normalize()
@@ -826,8 +826,7 @@ of that class.
826826

827827
.. method:: Element.removeAttribute(name)
828828

829-
Remove an attribute by name. If there is no matching attribute, a
830-
:exc:`NotFoundErr` is raised.
829+
Remove an attribute by name.
831830

832831

833832
.. method:: Element.removeAttributeNode(oldAttr)
@@ -838,8 +837,7 @@ of that class.
838837

839838
.. method:: Element.removeAttributeNS(namespaceURI, localName)
840839

841-
Remove an attribute by name. Note that it uses a localName, not a qname. No
842-
exception is raised if there is no matching attribute.
840+
Remove an attribute by name. Note that it uses a localName, not a qname.
843841

844842

845843
.. method:: Element.setAttribute(name, value)

0 commit comments

Comments
 (0)