Skip to content

API for BaseElement.extend method does not match that of lxml Element.extend

Commit 6f0c9ab5 added an extend method to inkex.elements.BaseElement. (This affects Inkscape >= 1.4.)

The new extend method does not work correctly if passed an iterator. It iterates over its argument several times. If an iterator is passed, it will be exhausted during the first iteration, with nothing left for the later iterations.

Previously, the extend method was inherited from lxml.etree._Element. That one works fine if passed an iterator. (It is documented to accept an arbitrary iterable.)

The new extend will only work correctly with containers (e.g. lists or sets) that can be repeatedly iterated. This violates the Liskov Substitution Principle: as things stand, instances of the subclass BaseElement are not usable anywhere its superclass _Element is usable.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information