From cb2469322b68cfc0c3761fdcb0cd6acafa0a3647 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Sat, 14 Apr 2012 11:13:38 -0400 Subject: Handle using provided weakrefs as stanza parent references. Fixes issue #159 --- sleekxmpp/xmlstream/stanzabase.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sleekxmpp/xmlstream/stanzabase.py') diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py index e1a2085a..2f6416d5 100644 --- a/sleekxmpp/xmlstream/stanzabase.py +++ b/sleekxmpp/xmlstream/stanzabase.py @@ -326,7 +326,10 @@ class ElementBase(object): #: If not, then :attr:`parent` is ``None``. self.parent = None if parent is not None: - self.parent = weakref.ref(parent) + if not isinstance(parent, weakref.ReferenceType): + self.parent = weakref.ref(parent) + else: + self.parent = parent if self.subitem is not None: for sub in self.subitem: -- cgit v1.2.3