summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sleekxmpp/test/sleektest.py6
-rw-r--r--sleekxmpp/xmlstream/xmlstream.py4
2 files changed, 7 insertions, 3 deletions
diff --git a/sleekxmpp/test/sleektest.py b/sleekxmpp/test/sleektest.py
index dd3df29a..364e5939 100644
--- a/sleekxmpp/test/sleektest.py
+++ b/sleekxmpp/test/sleektest.py
@@ -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'}
diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py
index f626eb00..4c4b1ebb 100644
--- a/sleekxmpp/xmlstream/xmlstream.py
+++ b/sleekxmpp/xmlstream/xmlstream.py
@@ -31,6 +31,8 @@ try:
except ImportError:
import Queue as queue
+from xml.parsers.expat import ExpatError
+
import sleekxmpp
from sleekxmpp.thirdparty.statemachine import StateMachine
from sleekxmpp.xmlstream import Scheduler, tostring
@@ -1241,7 +1243,7 @@ class XMLStream(object):
except SystemExit:
log.debug("SystemExit in _process")
shutdown = True
- except SyntaxError as e:
+ except (SyntaxError, ExpatError) as e:
log.error("Error reading from XML stream.")
self.exception(e)
except Socket.error as serr: