From d496417deb5a2c87fe8ad639e82d2b19ce94fc30 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Thu, 15 Dec 2011 12:02:08 -0800 Subject: [PATCH 1/8] Allow XEP-0082 to return datetime objects without having to format and reparse. --- sleekxmpp/plugins/xep_0082.py | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/sleekxmpp/plugins/xep_0082.py b/sleekxmpp/plugins/xep_0082.py index b1bb026..25c80fd 100644 --- a/sleekxmpp/plugins/xep_0082.py +++ b/sleekxmpp/plugins/xep_0082.py @@ -76,7 +76,7 @@ def format_datetime(time_obj): return '%sZ' % timestamp return timestamp -def date(year=None, month=None, day=None): +def date(year=None, month=None, day=None, obj=False): """ Create a date only timestamp for the given instant. @@ -86,6 +86,8 @@ def date(year=None, month=None, day=None): year -- Integer value of the year (4 digits) month -- Integer value of the month day -- Integer value of the day of the month. + obj -- If True, return the date object instead + of a formatted string. Defaults to False. """ today = dt.datetime.utcnow() if year is None: @@ -94,9 +96,12 @@ def date(year=None, month=None, day=None): month = today.month if day is None: day = today.day - return format_date(dt.date(year, month, day)) + value = dt.date(year, month, day) + if obj: + return value + return format_date(value) -def time(hour=None, min=None, sec=None, micro=None, offset=None): +def time(hour=None, min=None, sec=None, micro=None, offset=None, obj=False): """ Create a time only timestamp for the given instant. @@ -110,6 +115,8 @@ def time(hour=None, min=None, sec=None, micro=None, offset=None): offset -- Either a positive or negative number of seconds to offset from UTC to match a desired timezone, or a tzinfo object. + obj -- If True, return the time object instead + of a formatted string. Defaults to False. """ now = dt.datetime.utcnow() if hour is None: @@ -124,12 +131,14 @@ def time(hour=None, min=None, sec=None, micro=None, offset=None): offset = tzutc() elif not isinstance(offset, dt.tzinfo): offset = tzoffset(None, offset) - time = dt.time(hour, min, sec, micro, offset) - return format_time(time) + value = dt.time(hour, min, sec, micro, offset) + if obj: + return value + return format_time(value) def datetime(year=None, month=None, day=None, hour=None, min=None, sec=None, micro=None, offset=None, - separators=True): + separators=True, obj=False): """ Create a datetime timestamp for the given instant. @@ -146,6 +155,8 @@ def datetime(year=None, month=None, day=None, hour=None, offset -- Either a positive or negative number of seconds to offset from UTC to match a desired timezone, or a tzinfo object. + obj -- If True, return the datetime object instead + of a formatted string. Defaults to False. """ now = dt.datetime.utcnow() if year is None: @@ -167,9 +178,11 @@ def datetime(year=None, month=None, day=None, hour=None, elif not isinstance(offset, dt.tzinfo): offset = tzoffset(None, offset) - date = dt.datetime(year, month, day, hour, + value = dt.datetime(year, month, day, hour, min, sec, micro, offset) - return format_datetime(date) + if obj: + return value + return format_datetime(value) class xep_0082(base_plugin): From c98a22e065e81b5e01762e4eeedecb796a3954e1 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Thu, 15 Dec 2011 21:58:33 +0000 Subject: [PATCH 2/8] Fixed Issue 93: ACL.check jid parameter should be a string value --- sleekxmpp/plugins/xep_0009/remote.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sleekxmpp/plugins/xep_0009/remote.py b/sleekxmpp/plugins/xep_0009/remote.py index 1e3b504..8c08e8f 100644 --- a/sleekxmpp/plugins/xep_0009/remote.py +++ b/sleekxmpp/plugins/xep_0009/remote.py @@ -113,6 +113,9 @@ class ACL: def check(cls, rules, jid, resource): if rules is None: return cls.DENY # No rules means no access! + jid = str(jid) # Check the string representation of the JID. + if not jid: + return cls.DENY # Can't check an empty JID. for rule in rules: policy = cls._check(rule, jid, resource) if policy is not None: From 9950208d06357f199a6edb0b56bd23db9a8253c1 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Fri, 16 Dec 2011 17:41:16 +0000 Subject: [PATCH 3/8] Fixes Issue #123: Corrected boolean xml to python conversion --- sleekxmpp/plugins/xep_0009/binding.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sleekxmpp/plugins/xep_0009/binding.py b/sleekxmpp/plugins/xep_0009/binding.py index ef34b58..7743251 100644 --- a/sleekxmpp/plugins/xep_0009/binding.py +++ b/sleekxmpp/plugins/xep_0009/binding.py @@ -105,7 +105,7 @@ def _xml2py(value): if value.find('{%s}int' % namespace) is not None: return int(value.find('{%s}int' % namespace).text) if value.find('{%s}boolean' % namespace) is not None: - return bool(value.find('{%s}boolean' % namespace).text) + return bool(int(value.find('{%s}boolean' % namespace).text)) if value.find('{%s}string' % namespace) is not None: return value.find('{%s}string' % namespace).text if value.find('{%s}double' % namespace) is not None: From 2b3d11a7a5a7b8e04ca333d96d51f1c52fef2007 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Tue, 20 Dec 2011 02:01:34 -0500 Subject: [PATCH 4/8] XEP-0009: Added value conversion unit tests Added tests for bidirectional conversion of all XML-RPC data types --- tests/test_stanza_xep_0009.py | 247 +++++++++++++++++++++++++++++++++- 1 file changed, 240 insertions(+), 7 deletions(-) diff --git a/tests/test_stanza_xep_0009.py b/tests/test_stanza_xep_0009.py index 6186dd9..90cc879 100644 --- a/tests/test_stanza_xep_0009.py +++ b/tests/test_stanza_xep_0009.py @@ -6,23 +6,27 @@ See the file LICENSE for copying permission. """ +import base64 + from sleekxmpp.plugins.xep_0009.stanza.RPC import RPCQuery, MethodCall, \ MethodResponse -from sleekxmpp.plugins.xep_0009.binding import py2xml +from sleekxmpp.plugins.xep_0009.binding import py2xml, xml2py, rpcbase64, \ + rpctime from sleekxmpp.stanza.iq import Iq from sleekxmpp.test.sleektest import SleekTest from sleekxmpp.xmlstream.stanzabase import register_stanza_plugin +from sleekxmpp.xmlstream.tostring import tostring import unittest class TestJabberRPC(SleekTest): - + def setUp(self): register_stanza_plugin(Iq, RPCQuery) - register_stanza_plugin(RPCQuery, MethodCall) + register_stanza_plugin(RPCQuery, MethodCall) register_stanza_plugin(RPCQuery, MethodResponse) - + def testMethodCall(self): iq = self.Iq() iq['rpc_query']['method_call']['method_name'] = 'system.exit' @@ -50,6 +54,235 @@ class TestJabberRPC(SleekTest): """, use_values=False) - -suite = unittest.TestLoader().loadTestsFromTestCase(TestJabberRPC) - + + def testConvertNil(self): + params = [None] + params_xml = py2xml(*params) + expected_xml = self.parse_xml(""" + + + + + + + + """) + self.failUnless(self.compare(expected_xml, params_xml), + "Nil to XML conversion\nExpected: %s\nGot: %s" % ( + tostring(expected_xml), tostring(params_xml))) + self.assertEqual(params, xml2py(expected_xml), + "XML to nil conversion") + + def testConvertBoolean(self): + params = [True, False] + params_xml = py2xml(*params) + expected_xml = self.parse_xml(""" + + + + 1 + + + + + 0 + + + + """) + self.failUnless(self.compare(expected_xml, params_xml), + "Boolean to XML conversion\nExpected: %s\nGot: %s" % ( + tostring(expected_xml), tostring(params_xml))) + self.assertEqual(params, xml2py(expected_xml), + "XML to boolean conversion") + + def testConvertString(self): + params = ["'This' & \"That\""] + params_xml = py2xml(*params) + expected_xml = self.parse_xml(""" + + + + 'This' & "That" + + + + """) + self.failUnless(self.compare(expected_xml, params_xml), + "String to XML conversion\nExpected: %s\nGot: %s" % ( + tostring(expected_xml), tostring(params_xml))) + self.assertEqual(params, xml2py(expected_xml), + "XML to string conversion") + + def testConvertInteger(self): + params = [32767, -32768] + params_xml = py2xml(*params) + expected_xml = self.parse_xml(""" + + + + 32767 + + + + + -32768 + + + + """) + alternate_xml = self.parse_xml(""" + + + + 32767 + + + + + -32768 + + + + """) + self.failUnless(self.compare(expected_xml, params_xml), + "Integer to XML conversion\nExpected: %s\nGot: %s" % ( + tostring(expected_xml), tostring(params_xml))) + self.assertEqual(params, xml2py(expected_xml), + "XML to boolean conversion") + self.assertEqual(params, xml2py(alternate_xml), + "Alternate XML to boolean conversion") + + + def testConvertDouble(self): + params = [3.14159265] + params_xml = py2xml(*params) + expected_xml = self.parse_xml(""" + + + + 3.14159265 + + + + """) + self.failUnless(self.compare(expected_xml, params_xml), + "Double to XML conversion\nExpected: %s\nGot: %s" % ( + tostring(expected_xml), tostring(params_xml))) + self.assertEqual(params, xml2py(expected_xml), + "XML to double conversion") + + def testConvertBase64(self): + params = [rpcbase64(base64.encodestring("Hello, world!"))] + params_xml = py2xml(*params) + expected_xml = self.parse_xml(""" + + + + SGVsbG8sIHdvcmxkIQ== + + + + """) + alternate_xml = self.parse_xml(""" + + + + SGVsbG8sIHdvcmxkIQ== + + + + """) + self.failUnless(self.compare(expected_xml, params_xml), + "Base64 to XML conversion\nExpected: %s\nGot: %s" % ( + tostring(expected_xml), tostring(params_xml))) + self.assertEqual(map(lambda x: x.decode(), params), + map(lambda x: x.decode(), xml2py(expected_xml)), + "XML to base64 conversion") + self.assertEqual(map(lambda x: x.decode(), params), + map(lambda x: x.decode(), xml2py(alternate_xml)), + "Alternate XML to base64 conversion") + + def testConvertDateTime(self): + params = [rpctime("20111220T01:50:00")] + params_xml = py2xml(*params) + expected_xml = self.parse_xml(""" + + + + 20111220T01:50:00 + + + + """) + self.failUnless(self.compare(expected_xml, params_xml), + "DateTime to XML conversion\nExpected: %s\nGot: %s" % ( + tostring(expected_xml), tostring(params_xml))) + self.assertEqual(map(lambda x: x.iso8601(), params), + map(lambda x: x.iso8601(), xml2py(expected_xml)), + None) + + def testConvertArray(self): + params = [[1,2,3], ('a', 'b', 'c')] + params_xml = py2xml(*params) + expected_xml = self.parse_xml(""" + + + + + + 1 + 2 + 3 + + + + + + + + + a + b + c + + + + + + """) + self.failUnless(self.compare(expected_xml, params_xml), + "Array to XML conversion\nExpected: %s\nGot: %s" % ( + tostring(expected_xml), tostring(params_xml))) + self.assertEqual(map(list, params), xml2py(expected_xml), + "XML to array conversion") + + def testConvertStruct(self): + params = [{"foo": "bar", "baz": False}] + params_xml = py2xml(*params) + expected_xml = self.parse_xml(""" + + + + + + foo + bar + + + baz + 0 + + + + + + """) + self.failUnless(self.compare(expected_xml, params_xml), + "Struct to XML conversion\nExpected: %s\nGot: %s" % ( + tostring(expected_xml), tostring(params_xml))) + self.assertEqual(params, xml2py(expected_xml), + "XML to struct conversion") + +suite = unittest.TestLoader().loadTestsFromTestCase(TestJabberRPC) + From 6c58b8cc4bf5556b4df88ab3eb2ed53d164ad8de Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Tue, 20 Dec 2011 02:03:06 -0500 Subject: [PATCH 5/8] XEP-0009: Updated RPC value conversion code Updated the XML-RPC value conversion to correctly apply namespaces, and fixed an error uncovered by the tests in the XML -> Python conversion of dateTime values. --- sleekxmpp/plugins/xep_0009/binding.py | 38 +++++++++++++-------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/sleekxmpp/plugins/xep_0009/binding.py b/sleekxmpp/plugins/xep_0009/binding.py index 7743251..2c54b3b 100644 --- a/sleekxmpp/plugins/xep_0009/binding.py +++ b/sleekxmpp/plugins/xep_0009/binding.py @@ -42,46 +42,46 @@ def py2xml(*args): def _py2xml(*args): for x in args: - val = ET.Element("value") + val = ET.Element("{%s}value" % _namespace) if x is None: - nil = ET.Element("nil") + nil = ET.Element("{%s}nil" % _namespace) val.append(nil) elif type(x) is int: - i4 = ET.Element("i4") + i4 = ET.Element("{%s}i4" % _namespace) i4.text = str(x) val.append(i4) elif type(x) is bool: - boolean = ET.Element("boolean") + boolean = ET.Element("{%s}boolean" % _namespace) boolean.text = str(int(x)) val.append(boolean) elif type(x) is str: - string = ET.Element("string") + string = ET.Element("{%s}string" % _namespace) string.text = x val.append(string) elif type(x) is float: - double = ET.Element("double") + double = ET.Element("{%s}double" % _namespace) double.text = str(x) val.append(double) elif type(x) is rpcbase64: - b64 = ET.Element("base64") + b64 = ET.Element("{%s}base64" % _namespace) b64.text = x.encoded() val.append(b64) elif type(x) is rpctime: - iso = ET.Element("dateTime.iso8601") + iso = ET.Element("{%s}dateTime.iso8601" % _namespace) iso.text = str(x) val.append(iso) elif type(x) in (list, tuple): - array = ET.Element("array") - data = ET.Element("data") + array = ET.Element("{%s}array" % _namespace) + data = ET.Element("{%s}data" % _namespace) for y in x: data.append(_py2xml(y)) array.append(data) val.append(array) elif type(x) is dict: - struct = ET.Element("struct") + struct = ET.Element("{%s}struct" % _namespace) for y in x.keys(): - member = ET.Element("member") - name = ET.Element("name") + member = ET.Element("{%s}member" % _namespace) + name = ET.Element("{%s}name" % _namespace) name.text = y member.append(name) member.append(_py2xml(x[y])) @@ -110,13 +110,13 @@ def _xml2py(value): return value.find('{%s}string' % namespace).text if value.find('{%s}double' % namespace) is not None: return float(value.find('{%s}double' % namespace).text) - if value.find('{%s}base64') is not None: - return rpcbase64(value.find('base64' % namespace).text) - if value.find('{%s}Base64') is not None: + if value.find('{%s}base64' % namespace) is not None: + return rpcbase64(value.find('{%s}base64' % namespace).text) + if value.find('{%s}Base64' % namespace) is not None: # Older versions of XEP-0009 used Base64 - return rpcbase64(value.find('Base64' % namespace).text) - if value.find('{%s}dateTime.iso8601') is not None: - return rpctime(value.find('{%s}dateTime.iso8601')) + return rpcbase64(value.find('{%s}Base64' % namespace).text) + if value.find('{%s}dateTime.iso8601' % namespace) is not None: + return rpctime(value.find('{%s}dateTime.iso8601' % namespace).text) if value.find('{%s}struct' % namespace) is not None: struct = {} for member in value.find('{%s}struct' % namespace).findall('{%s}member' % namespace): From fb55d9e9d1ffd9ebec18dcf101308ac89dc865ad Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Tue, 20 Dec 2011 12:30:35 -0500 Subject: [PATCH 6/8] Add comma to fix pubsub error conditions. Fixes issue #127 --- sleekxmpp/plugins/xep_0060/stanza/pubsub_errors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sleekxmpp/plugins/xep_0060/stanza/pubsub_errors.py b/sleekxmpp/plugins/xep_0060/stanza/pubsub_errors.py index 46374a3..aeaeefe 100644 --- a/sleekxmpp/plugins/xep_0060/stanza/pubsub_errors.py +++ b/sleekxmpp/plugins/xep_0060/stanza/pubsub_errors.py @@ -22,7 +22,7 @@ class PubsubErrorCondition(ElementBase): 'max-items-exceeded', 'max-nodes-exceeded', 'nodeid-required', 'not-in-roster-group', 'not-subscribed', 'payload-too-big', - 'payload-required' 'pending-subscription', + 'payload-required', 'pending-subscription', 'presence-subscription-required', 'subid-required', 'too-many-subscriptions', 'unsupported')) condition_ns = 'http://jabber.org/protocol/pubsub#errors' From e928b9c4341a7f49896ec13c1c4bf325ee708e00 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Tue, 20 Dec 2011 21:19:51 -0500 Subject: [PATCH 7/8] XEP-0009: Updated tests to work in python 3 --- sleekxmpp/plugins/xep_0009/binding.py | 10 ++++---- tests/test_stanza_xep_0009.py | 34 +++++++++++++-------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/sleekxmpp/plugins/xep_0009/binding.py b/sleekxmpp/plugins/xep_0009/binding.py index 2c54b3b..b439570 100644 --- a/sleekxmpp/plugins/xep_0009/binding.py +++ b/sleekxmpp/plugins/xep_0009/binding.py @@ -111,10 +111,10 @@ def _xml2py(value): if value.find('{%s}double' % namespace) is not None: return float(value.find('{%s}double' % namespace).text) if value.find('{%s}base64' % namespace) is not None: - return rpcbase64(value.find('{%s}base64' % namespace).text) + return rpcbase64(value.find('{%s}base64' % namespace).text.encode()) if value.find('{%s}Base64' % namespace) is not None: # Older versions of XEP-0009 used Base64 - return rpcbase64(value.find('{%s}Base64' % namespace).text) + return rpcbase64(value.find('{%s}Base64' % namespace).text.encode()) if value.find('{%s}dateTime.iso8601' % namespace) is not None: return rpctime(value.find('{%s}dateTime.iso8601' % namespace).text) if value.find('{%s}struct' % namespace) is not None: @@ -138,13 +138,13 @@ class rpcbase64(object): self.data = data def decode(self): - return base64.decodestring(self.data) + return base64.b64decode(self.data) def __str__(self): - return self.decode() + return self.decode().decode() def encoded(self): - return self.data + return self.data.decode() diff --git a/tests/test_stanza_xep_0009.py b/tests/test_stanza_xep_0009.py index 90cc879..3680033 100644 --- a/tests/test_stanza_xep_0009.py +++ b/tests/test_stanza_xep_0009.py @@ -67,7 +67,7 @@ class TestJabberRPC(SleekTest): """) - self.failUnless(self.compare(expected_xml, params_xml), + self.assertTrue(self.compare(expected_xml, params_xml), "Nil to XML conversion\nExpected: %s\nGot: %s" % ( tostring(expected_xml), tostring(params_xml))) self.assertEqual(params, xml2py(expected_xml), @@ -90,7 +90,7 @@ class TestJabberRPC(SleekTest): """) - self.failUnless(self.compare(expected_xml, params_xml), + self.assertTrue(self.compare(expected_xml, params_xml), "Boolean to XML conversion\nExpected: %s\nGot: %s" % ( tostring(expected_xml), tostring(params_xml))) self.assertEqual(params, xml2py(expected_xml), @@ -108,7 +108,7 @@ class TestJabberRPC(SleekTest): """) - self.failUnless(self.compare(expected_xml, params_xml), + self.assertTrue(self.compare(expected_xml, params_xml), "String to XML conversion\nExpected: %s\nGot: %s" % ( tostring(expected_xml), tostring(params_xml))) self.assertEqual(params, xml2py(expected_xml), @@ -145,7 +145,7 @@ class TestJabberRPC(SleekTest): """) - self.failUnless(self.compare(expected_xml, params_xml), + self.assertTrue(self.compare(expected_xml, params_xml), "Integer to XML conversion\nExpected: %s\nGot: %s" % ( tostring(expected_xml), tostring(params_xml))) self.assertEqual(params, xml2py(expected_xml), @@ -166,14 +166,14 @@ class TestJabberRPC(SleekTest): """) - self.failUnless(self.compare(expected_xml, params_xml), + self.assertTrue(self.compare(expected_xml, params_xml), "Double to XML conversion\nExpected: %s\nGot: %s" % ( tostring(expected_xml), tostring(params_xml))) self.assertEqual(params, xml2py(expected_xml), "XML to double conversion") def testConvertBase64(self): - params = [rpcbase64(base64.encodestring("Hello, world!"))] + params = [rpcbase64(base64.b64encode(b"Hello, world!"))] params_xml = py2xml(*params) expected_xml = self.parse_xml(""" @@ -193,14 +193,14 @@ class TestJabberRPC(SleekTest): """) - self.failUnless(self.compare(expected_xml, params_xml), + self.assertTrue(self.compare(expected_xml, params_xml), "Base64 to XML conversion\nExpected: %s\nGot: %s" % ( tostring(expected_xml), tostring(params_xml))) - self.assertEqual(map(lambda x: x.decode(), params), - map(lambda x: x.decode(), xml2py(expected_xml)), + self.assertEqual(list(map(lambda x: x.decode(), params)), + list(map(lambda x: x.decode(), xml2py(expected_xml))), "XML to base64 conversion") - self.assertEqual(map(lambda x: x.decode(), params), - map(lambda x: x.decode(), xml2py(alternate_xml)), + self.assertEqual(list(map(lambda x: x.decode(), params)), + list(map(lambda x: x.decode(), xml2py(alternate_xml))), "Alternate XML to base64 conversion") def testConvertDateTime(self): @@ -215,11 +215,11 @@ class TestJabberRPC(SleekTest): """) - self.failUnless(self.compare(expected_xml, params_xml), + self.assertTrue(self.compare(expected_xml, params_xml), "DateTime to XML conversion\nExpected: %s\nGot: %s" % ( tostring(expected_xml), tostring(params_xml))) - self.assertEqual(map(lambda x: x.iso8601(), params), - map(lambda x: x.iso8601(), xml2py(expected_xml)), + self.assertEqual(list(map(lambda x: x.iso8601(), params)), + list(map(lambda x: x.iso8601(), xml2py(expected_xml))), None) def testConvertArray(self): @@ -251,10 +251,10 @@ class TestJabberRPC(SleekTest): """) - self.failUnless(self.compare(expected_xml, params_xml), + self.assertTrue(self.compare(expected_xml, params_xml), "Array to XML conversion\nExpected: %s\nGot: %s" % ( tostring(expected_xml), tostring(params_xml))) - self.assertEqual(map(list, params), xml2py(expected_xml), + self.assertEqual(list(map(list, params)), xml2py(expected_xml), "XML to array conversion") def testConvertStruct(self): @@ -278,7 +278,7 @@ class TestJabberRPC(SleekTest): """) - self.failUnless(self.compare(expected_xml, params_xml), + self.assertTrue(self.compare(expected_xml, params_xml), "Struct to XML conversion\nExpected: %s\nGot: %s" % ( tostring(expected_xml), tostring(params_xml))) self.assertEqual(params, xml2py(expected_xml), From 42a86fe0d407521ba23b21ba5d95fa2779186ddb Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Tue, 27 Dec 2011 18:01:26 -0500 Subject: [PATCH 8/8] Disconnect when a SyntaxError is found. This should resolve issue #102 --- sleekxmpp/xmlstream/xmlstream.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py index 3e56908..fb9f91b 100644 --- a/sleekxmpp/xmlstream/xmlstream.py +++ b/sleekxmpp/xmlstream/xmlstream.py @@ -1159,6 +1159,7 @@ class XMLStream(object): shutdown = True except SyntaxError as e: log.error("Error reading from XML stream.") + shutdown = True self.exception(e) except Socket.error as serr: self.event('socket_error', serr)