Fix 'dictionary changed size during iteration'.

This commit is contained in:
Valentin Lorentz 2013-05-10 23:55:48 +02:00
parent cb6139e110
commit 3935152d65
3 changed files with 7 additions and 2 deletions

View File

@ -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

View File

@ -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.

View File

@ -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