From 3935152d656dd051bfb6e5fb5b5c7bd63d575b41 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Fri, 10 May 2013 23:55:48 +0200 Subject: [PATCH] Fix 'dictionary changed size during iteration'. --- plugins/String/plugin.py | 2 +- plugins/String/test.py | 4 ++++ src/plugin.py | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/String/plugin.py b/plugins/String/plugin.py index 5a4c4b123..8f2bc6428 100644 --- a/plugins/String/plugin.py +++ b/plugins/String/plugin.py @@ -228,7 +228,7 @@ class String(callbacks.Plugin): http://www.rsasecurity.com/rsalabs/faq/3-6-6.html for more information about md5. """ - irc.reply(utils.crypt.md5(text).hexdigest()) + irc.reply(utils.crypt.md5(text.encode('utf8')).hexdigest()) md5 = wrap(md5, ['text']) @internationalizeDocstring diff --git a/plugins/String/test.py b/plugins/String/test.py index da11bf1a3..fa8875923 100644 --- a/plugins/String/test.py +++ b/plugins/String/test.py @@ -98,6 +98,10 @@ class StringTestCase(PluginTestCase): i = ord(c) self.assertResponse('ord %s' % utils.str.dqrepr(c), str(i)) + def testMd5(self): + self.assertResponse('md5 supybot', '630f4afcfb53c9e84c0a95064bd6add3') + + def testEncodeDecode(self): # This no longer works correctly. It almost seems like were throwing # in a repr() somewhere. diff --git a/src/plugin.py b/src/plugin.py index 4008d479f..36aa03d42 100644 --- a/src/plugin.py +++ b/src/plugin.py @@ -60,7 +60,8 @@ def loadPluginModule(name, ignoreDeprecation=False): module = imp.load_module(name, *moduleInfo) except: sys.modules.pop(name, None) - for key in sys.modules: + keys = sys.modules.keys() + for key in keys: if key.startswith(name + '.'): sys.modules.pop(key) raise