[docutils:bugs] #448 `Element.index()` returns incorrect results for `Text` nodes

"Günter Milde" via Docutils-develop <[email protected]>
Newsgroups gmane.text.docutils.devel
Message-ID </p/docutils/bugs/448/b13460a72c629f1b958179f5f8e56277ecf87500.bugs@docutils.p.sourceforge.net>
- **status**: open-fixed --> closed-fixed
- **Comment**:

Fixed in Docutils 0.19.
Thank you for reporting.



---

** [bugs:#448] `Element.index()` returns incorrect results for `Text` nodes**

**Status:** closed-fixed
**Created:** Tue May 24, 2022 11:38 PM UTC by Adam  Turner
**Last Updated:** Fri Jun 10, 2022 11:12 AM UTC
**Owner:** nobody


This captures the bug behind `branches/index-bug`. I'm not sure the general case of `index` is worth fixing, as `Text` nodes are a special case, but it might have implications for `Node.findall`.


```python
>>> from docutils import nodes
>>> tree = nodes.Element()
>>> blah1 = nodes.Text("blah")
>>> blah2 = nodes.Text("blah")
>>> tree += [nodes.Text("node1"), blah1, blah2]
>>> print(tree.pformat())
<Element>
    node1
    blah
    blah

>>> tree[tree.index(blah2)] is blah2
False
>>> tree[tree.index(blah2)] is blah1
True
```

A


---

Sent from sourceforge.net because [email protected] is subscribed to https://sourceforge.net/p/docutils/bugs/

To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/docutils/admin/bugs/options.  Or, if this is a mailing list, you can unsubscribe from the mailing list.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.