summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-09-01 00:50:45 -0700
committerLance Stout <lancestout@gmail.com>2011-09-01 00:50:45 -0700
commit0af35c2224889a06e5ac25028ee5b489106d201b (patch)
tree057e5f670881dd9769c67890e97f55093458a60c
parent76bc0a2ba679828d17871c43bfe076b077c9b600 (diff)
downloadslixmpp-0af35c2224889a06e5ac25028ee5b489106d201b.tar.gz
slixmpp-0af35c2224889a06e5ac25028ee5b489106d201b.tar.bz2
slixmpp-0af35c2224889a06e5ac25028ee5b489106d201b.tar.xz
slixmpp-0af35c2224889a06e5ac25028ee5b489106d201b.zip
Fix memory reference bugs.
-rw-r--r--sleekxmpp/xmlstream/stanzabase.py16
-rw-r--r--tests/test_stream_xep_0060.py2
2 files changed, 13 insertions, 5 deletions
diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py
index a2826ead..1ff89554 100644
--- a/sleekxmpp/xmlstream/stanzabase.py
+++ b/sleekxmpp/xmlstream/stanzabase.py
@@ -39,15 +39,23 @@ def register_stanza_plugin(stanza, plugin, iterable=False, overrides=False):
the parent stanza.
"""
tag = "{%s}%s" % (plugin.namespace, plugin.name)
+
+ # Prevent weird memory reference gotchas by ensuring
+ # that the parent stanza class has its own set of
+ # plugin info maps and is not using the mappings from
+ # an ancestor class (like ElementBase).
+ plugin_info = ('plugin_attrib_map', 'plugin_tag_map',
+ 'plugin_iterables', 'plugin_overrides')
+ for attr in plugin_info:
+ info = getattr(stanza, attr)
+ setattr(stanza, attr, info.copy())
+
stanza.plugin_attrib_map[plugin.plugin_attrib] = plugin
stanza.plugin_tag_map[tag] = plugin
+
if iterable:
- # Prevent weird memory reference gotchas.
- stanza.plugin_iterables = stanza.plugin_iterables.copy()
stanza.plugin_iterables.add(plugin)
if overrides:
- # Prevent weird memory reference gotchas.
- stanza.plugin_overrides = stanza.plugin_overrides.copy()
for interface in plugin.overrides:
stanza.plugin_overrides[interface] = plugin.plugin_attrib
diff --git a/tests/test_stream_xep_0060.py b/tests/test_stream_xep_0060.py
index 626cea98..4e2dca6d 100644
--- a/tests/test_stream_xep_0060.py
+++ b/tests/test_stream_xep_0060.py
@@ -460,7 +460,7 @@ class TestStreamPubsub(SleekTest):
</retract>
</pubsub>
</iq>
- """, use_values=False)
+ """)
def testPurge(self):
"""Test removing all items from a node."""