ElementTree's Element substitution in Python 3

André andre.roberge at gmail.com
Fri Jul 24 21:48:02 CEST 2009

On Jul 24, 4:17 pm, Piet van Oostrum <p... at cs.uu.nl> wrote:
> >>>>> André <andre.robe... at gmail.com> (A) a écrit:
> >A> I have a function to replace the content of an ElementTree Element by
> >A> that of another one which works using Python 2 but not with Python 3.
> >A> I get an assertion error.


> >A> Traceback (most recent call last):
> >A>   File "test.py", line 7, in <module>
> >A>     a[:] = c[:]
> >A>   File "/usr/local/py3.1/lib/python3.1/xml/etree/ElementTree.py", line
> >A> 210, in __setitem__
> >A>     assert iselement(element)
> >A> AssertionError
> This is a Python bug. Please report it.


> The problem is that in Python 3
> slice assignments are done with __setitem__ rather than __setslice__ but
> ElementTree has not been adapted to that.
> --
> Piet van Oostrum <p... at cs.uu.nl>
> URL:http://pietvanoostrum.com[PGP 8DAE142BE17999C4]
> Private email: p... at vanoostrum.org

More information about the Python-list mailing list