xml.etree.ElementTree raises ExpatError instead of SyntaxError or ParseError.

This commit is contained in:
Lance Stout
2012-02-19 20:27:19 -08:00
parent afe0d16797
commit c36073b40e
2 changed files with 7 additions and 3 deletions

View File

@@ -7,6 +7,7 @@
"""
import unittest
from xml.parsers.expat import ExpatError
try:
import Queue as queue
except:
@@ -62,8 +63,9 @@ class SleekTest(unittest.TestCase):
try:
xml = ET.fromstring(xml_string)
return xml
except SyntaxError as e:
if 'unbound' in e.msg:
except (SyntaxError, ExpatError) as e:
msg = e.msg if hasattr(e, 'msg') else e.message
if 'unbound' in msg:
known_prefixes = {
'stream': 'http://etherx.jabber.org/streams'}