diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py index 64020c8..a0d8f5d 100644 --- a/sleekxmpp/xmlstream/stanzabase.py +++ b/sleekxmpp/xmlstream/stanzabase.py @@ -10,6 +10,7 @@ import logging import traceback import sys import weakref +import copy if sys.version_info < (3,0): from . import tostring26 as tostring @@ -308,6 +309,9 @@ class ElementBase(tostring.ToString): def appendxml(self, xml): self.xml.append(xml) return self + + def __copy__(self): + return self.__class__(xml=copy.copy(self.xml), parent=self.parent) #def __del__(self): #prevents garbage collection of reference cycle # if self.parent is not None: @@ -386,3 +390,6 @@ class StanzaBase(ElementBase): def send(self): self.stream.sendRaw(self.__str__()) + def __copy__(self): + return self.__class__(xml=copy.copy(self.xml), stream=self.stream) +