diff options
author | mathieui <mathieui@mathieui.net> | 2015-02-12 12:17:01 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2015-02-12 12:17:01 +0100 |
commit | f6b3a0c6cffa5ebf10d20c20b5cadd575c91fe81 (patch) | |
tree | aa566e12ee940d2df17541d5aa53ec38aba162fc /slixmpp/xmlstream/stanzabase.py | |
parent | 8b36e918e897a55622c279507a7bc886fdfb1081 (diff) | |
download | slixmpp-f6b3a0c6cffa5ebf10d20c20b5cadd575c91fe81.tar.gz slixmpp-f6b3a0c6cffa5ebf10d20c20b5cadd575c91fe81.tar.bz2 slixmpp-f6b3a0c6cffa5ebf10d20c20b5cadd575c91fe81.tar.xz slixmpp-f6b3a0c6cffa5ebf10d20c20b5cadd575c91fe81.zip |
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.
Diffstat (limited to 'slixmpp/xmlstream/stanzabase.py')
-rw-r--r-- | slixmpp/xmlstream/stanzabase.py | 11 |
1 files changed, 6 insertions, 5 deletions
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'``.""" |