Catch cElementTree TypeError

- Hopefully fixes #559
This commit is contained in:
croneter 2018-11-26 20:44:36 +01:00
parent 36d14ffdcf
commit a10e3925d5

View file

@ -652,8 +652,9 @@ class XmlKodiSetting(object):
def __enter__(self):
try:
self.tree = defused_etree.parse(self.path)
except IOError:
except (IOError, TypeError):
# Document is blank or missing
# OR (TypeError): Fuck-up if file is empty
if self.force_create is False:
LOG.debug('%s does not seem to exist; not creating', self.path)
# This will abort __enter__
@ -669,6 +670,7 @@ class XmlKodiSetting(object):
self.filename,
'http://kodi.wiki'))
self.__exit__(ParseError('Error parsing XML'), None, None)
raise ParseError
self.root = self.tree.getroot()
return self