mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-27 11:09:56 +00:00
Fix memory reference bugs.
This commit is contained in:
parent
76bc0a2ba6
commit
0af35c2224
2 changed files with 13 additions and 5 deletions
|
@ -39,15 +39,23 @@ def register_stanza_plugin(stanza, plugin, iterable=False, overrides=False):
|
||||||
the parent stanza.
|
the parent stanza.
|
||||||
"""
|
"""
|
||||||
tag = "{%s}%s" % (plugin.namespace, plugin.name)
|
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_attrib_map[plugin.plugin_attrib] = plugin
|
||||||
stanza.plugin_tag_map[tag] = plugin
|
stanza.plugin_tag_map[tag] = plugin
|
||||||
|
|
||||||
if iterable:
|
if iterable:
|
||||||
# Prevent weird memory reference gotchas.
|
|
||||||
stanza.plugin_iterables = stanza.plugin_iterables.copy()
|
|
||||||
stanza.plugin_iterables.add(plugin)
|
stanza.plugin_iterables.add(plugin)
|
||||||
if overrides:
|
if overrides:
|
||||||
# Prevent weird memory reference gotchas.
|
|
||||||
stanza.plugin_overrides = stanza.plugin_overrides.copy()
|
|
||||||
for interface in plugin.overrides:
|
for interface in plugin.overrides:
|
||||||
stanza.plugin_overrides[interface] = plugin.plugin_attrib
|
stanza.plugin_overrides[interface] = plugin.plugin_attrib
|
||||||
|
|
||||||
|
|
|
@ -460,7 +460,7 @@ class TestStreamPubsub(SleekTest):
|
||||||
</retract>
|
</retract>
|
||||||
</pubsub>
|
</pubsub>
|
||||||
</iq>
|
</iq>
|
||||||
""", use_values=False)
|
""")
|
||||||
|
|
||||||
def testPurge(self):
|
def testPurge(self):
|
||||||
"""Test removing all items from a node."""
|
"""Test removing all items from a node."""
|
||||||
|
|
Loading…
Reference in a new issue