[issue41892] use both "for in" and "ElementTree.remove" has a index bug

Eric V. Smith report at bugs.python.org
Thu Oct 1 11:34:14 EDT 2020


Eric V. Smith <eric at trueblade.com> added the comment:

I can't say how ElementTree works without more checking, but this solution cannot work in general. Given a pointer to an object that's in a list, how would you get to the next item? Say the parent list-like object has a C array of pointers to the objects it contains, and removing one of the objects re-shuffles that list. How would keeping a pointer to the current object help you?

In any event, I don't think this behavior is going to change.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41892>
_______________________________________


More information about the Python-bugs-list mailing list