mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-27 19:19:54 +00:00
xml.etree.ElementTree raises ExpatError instead of SyntaxError or ParseError.
This commit is contained in:
parent
afe0d16797
commit
c36073b40e
2 changed files with 7 additions and 3 deletions
|
@ -7,6 +7,7 @@
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
from xml.parsers.expat import ExpatError
|
||||||
try:
|
try:
|
||||||
import Queue as queue
|
import Queue as queue
|
||||||
except:
|
except:
|
||||||
|
@ -62,8 +63,9 @@ class SleekTest(unittest.TestCase):
|
||||||
try:
|
try:
|
||||||
xml = ET.fromstring(xml_string)
|
xml = ET.fromstring(xml_string)
|
||||||
return xml
|
return xml
|
||||||
except SyntaxError as e:
|
except (SyntaxError, ExpatError) as e:
|
||||||
if 'unbound' in e.msg:
|
msg = e.msg if hasattr(e, 'msg') else e.message
|
||||||
|
if 'unbound' in msg:
|
||||||
known_prefixes = {
|
known_prefixes = {
|
||||||
'stream': 'http://etherx.jabber.org/streams'}
|
'stream': 'http://etherx.jabber.org/streams'}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,8 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import Queue as queue
|
import Queue as queue
|
||||||
|
|
||||||
|
from xml.parsers.expat import ExpatError
|
||||||
|
|
||||||
import sleekxmpp
|
import sleekxmpp
|
||||||
from sleekxmpp.thirdparty.statemachine import StateMachine
|
from sleekxmpp.thirdparty.statemachine import StateMachine
|
||||||
from sleekxmpp.xmlstream import Scheduler, tostring
|
from sleekxmpp.xmlstream import Scheduler, tostring
|
||||||
|
@ -1241,7 +1243,7 @@ class XMLStream(object):
|
||||||
except SystemExit:
|
except SystemExit:
|
||||||
log.debug("SystemExit in _process")
|
log.debug("SystemExit in _process")
|
||||||
shutdown = True
|
shutdown = True
|
||||||
except SyntaxError as e:
|
except (SyntaxError, ExpatError) as e:
|
||||||
log.error("Error reading from XML stream.")
|
log.error("Error reading from XML stream.")
|
||||||
self.exception(e)
|
self.exception(e)
|
||||||
except Socket.error as serr:
|
except Socket.error as serr:
|
||||||
|
|
Loading…
Reference in a new issue