From f6b3a0c6cffa5ebf10d20c20b5cadd575c91fe81 Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 12 Feb 2015 12:17:01 +0100 Subject: Fix the uses of stanza.reply() This is relying on the stanzas being copied for each handler. We no longer do that for performance reasons, so instead of editing the copy in-place, stanza.reply() now returns a new stanza. --- slixmpp/xmlstream/stanzabase.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'slixmpp/xmlstream/stanzabase.py') diff --git a/slixmpp/xmlstream/stanzabase.py b/slixmpp/xmlstream/stanzabase.py index 82064c1d..392fd55b 100644 --- a/slixmpp/xmlstream/stanzabase.py +++ b/slixmpp/xmlstream/stanzabase.py @@ -1538,16 +1538,17 @@ class StanzaBase(ElementBase): :param bool clear: Indicates if the stanza's contents should be removed. Defaults to ``True``. """ + new_stanza = copy.copy(self) # if it's a component, use from if self.stream and hasattr(self.stream, "is_component") and \ self.stream.is_component: - self['from'], self['to'] = self['to'], self['from'] + new_stanza['from'], new_stanza['to'] = self['to'], self['from'] else: - self['to'] = self['from'] - del self['from'] + new_stanza['to'] = self['from'] + del new_stanza['from'] if clear: - self.clear() - return self + new_stanza.clear() + return new_stanza def error(self): """Set the stanza's type to ``'error'``.""" -- cgit v1.2.3