Skip to main content

the beauty of free software

I'm on Debian testing and I rely heavily on vdirsyncer 1 from pimutils for syncing my calendar, todo-list(s) and contacts between devices. I've been using this setup for quite some time now and it works pretty well.

After some dreaded apt upgrade, maybe in combination with a pip3 install --upgrade stuff, somewhere along the line, vdirsyncer broke down on me. Instead of thoroughly reading the Python error I tried for several days to reinstall it via different routes but I never got it to work.

Finally I had enough and back traced to my initial broken state and actually read the Python error:

'xml.etree.ElementTree.Element' object has no attribute 'getiterator'

I googled the error and found this helpful snippet on github:

Methods getchildren() and getiterator() of classes ElementTree and Element in the ElementTree module have been removed. They were deprecated in Python 3.2. Use iter(x) or list(x) instead of x.getchildren() and x.iter() or list(x.iter()) instead of x.getiterator(). (Contributed by Serhiy Storchaka in bpo-36543.)

https://docs.python.org/3.9/whatsnew/3.9.html#removed

I have created #7 to fix this.

This looked straightforward and gave me some hope of an easy doable fix. I then ran:

grep -Ril "getiterator" /usr/local/lib/python3.9/dist-packages/vdirsyncer/

which outed the damn culprit:

/usr/local/lib/python3.9/dist-packages/vdirsyncer/storage/dav.py

in particular, in dav.py on line 123, we need to replace one line in the function

def _merge_xml(items):
    if not items:
        return None
    rv = items[0]
    for item in items[1:]:
#        rv.extend(item.getiterator())
        rv.extend(item.iter())
    return rv

as indicated above and that's it, vdirsyncer works again!

I was so happy when I managed to fix it so I thought about doing a pull request but it turns out that this is already fixed upstream and it is just the pip repository lagging behind.

I could have solved this in a couple of minutes instead of days if I just had read the error to begin with. A willingness to dig into the code and change one line was all it took.

Even though this was very low hanging fruit it's a very nice feeling to say "fuck it" and do it yourself, something that in all likelihood would not have been possible if I had to deal with some closed down proprietary solution. It's such a simple thing but yet so empowering.