From d8d9e8df16c07bd13bbac72e4445a2930407b244 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Mon, 20 Jun 2011 16:25:56 -0700 Subject: Fix stanza clobbering when replying to errors. If a stanza handler raised an exception, the exception was processed and replied by the modified stanza, not a stanza with the original content. A copy is now made before handler processing, and if an exception occurs it is the copy that processes the exception using the original content. --- tests/test_stream_exceptions.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'tests/test_stream_exceptions.py') diff --git a/tests/test_stream_exceptions.py b/tests/test_stream_exceptions.py index bc01c2a7..1143ce28 100644 --- a/tests/test_stream_exceptions.py +++ b/tests/test_stream_exceptions.py @@ -15,6 +15,35 @@ class TestStreamExceptions(SleekTest): sys.excepthook = sys.__excepthook__ self.stream_close() + def testExceptionReply(self): + """Test that raising an exception replies with the original stanza.""" + + def message(msg): + msg.reply() + msg['body'] = 'Body changed' + raise XMPPError(clear=False) + + + sys.excepthook = lambda *args, **kwargs: None + self.stream_start() + self.xmpp.add_event_handler('message', message) + + self.recv(""" + + This is going to cause an error. + + """) + + self.send(""" + + This is going to cause an error. + + + + + """) + def testXMPPErrorException(self): """Test raising an XMPPError exception.""" -- cgit v1.2.3