Bug #3434

XML parsing error in complex installation

Added by marconfus 3 months ago. Updated 3 months ago.

Start date:
Due date:
% Done:


Estimated time:


slixmpp is used in Home Assistant and since the latest version (of HA) it started to show some very strange behaviour:

Long story short, the following exception occurs, no matter what server one connects to.

2019-02-08 10:41:01 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback _SelectorSocketTransport._read_ready()
Traceback (most recent call last):
  File "/usr/lib/python3.6/asyncio/", line 145, in _run
  File "/usr/lib/python3.6/asyncio/", line 732, in _read_ready
  File "/home/hass/homeassistant/lib/python3.6/site-packages/slixmpp/xmlstream/", line 406, in data_received
  File "/home/hass/homeassistant/lib/python3.6/site-packages/slixmpp/xmlstream/", line 970, in _spawn_event
    stanza = self._build_stanza(xml)
  File "/home/hass/homeassistant/lib/python3.6/site-packages/slixmpp/xmlstream/", line 951, in _build_stanza
    stanza = stanza_type(self, xml)
  File "/home/hass/homeassistant/lib/python3.6/site-packages/slixmpp/xmlstream/", line 1389, in __init__
    ElementBase.__init__(self, xml, parent)
  File "/home/hass/homeassistant/lib/python3.6/site-packages/slixmpp/xmlstream/", line 415, in __init__
    if self.setup(xml):
  File "/home/hass/homeassistant/lib/python3.6/site-packages/slixmpp/stanza/", line 27, in setup
    self.values = self.values
  File "/home/hass/homeassistant/lib/python3.6/site-packages/slixmpp/xmlstream/", line 614, in _set_stanza_values
    self[full_interface] = value
  File "/home/hass/homeassistant/lib/python3.6/site-packages/slixmpp/xmlstream/", line 752, in __setitem__
  File "/home/hass/homeassistant/lib/python3.6/site-packages/slixmpp/xmlstream/", line 958, in _set_sub_text
    return self._del_sub(name, lang=lang)
  File "/home/hass/homeassistant/lib/python3.6/site-packages/slixmpp/xmlstream/", line 1039, in _del_sub
    parent = self.xml.find(parent_path)
  File "/usr/lib/python3.6/xml/etree/", line 298, in find
    return ElementPath.find(self, path, namespaces)
  File "/usr/lib/python3.6/xml/etree/", line 298, in find
    return next(iterfind(elem, path, namespaces), None)
TypeError: 'NoneType' object is not an iterator

This happens when the first callback while starting a connection to an XMPP server comes in.

It's strange because it doesn't happen all the time. When the error occurs, it occurs all the time as long as the python process is running. But sometimes it doesn''t occur and then it also doesn''t occur all the time as long as the process is running. It also only happens when Home Assistant is started with a lot/certain(?) modules. Not in a "small installation" i.e. not a lot of other modules are loaded.

I've looked into it and in both cases exactly the same XML document is received. So I have no clue why the XML parser sometimes fails and sometimes not.

I modified slixmpp to use lxml instead of xml. In and I replaced

from xml.etree import cElementTree as ET

from lxml import etree as ET

and added a try/catch block to around the line from the stacktrace.

                parent = self.xml.find(parent_path)
                parent = None

Just adding the try/catch block without switching to lxml leads to other errors.
And now it seems to be reliably working!

Any idea what is going on here and how it can be fixed globally?


#1 Updated by pep. 3 months ago


This tracker is not used anymore, and issues are now being tracked at

If you can tell us where you found the url, we'll also make sure to change/redirect it.

#2 Updated by marconfus 3 months ago

Ah, that one looks much more alive :-)

It's right on the frontpage (the first Google result when you search for "slixmpp"):

Perhaps you could also add a link to the Github mirror, as it's the second result.

I'll open it again there then.

Also available in: Atom PDF