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 http://www.rsasecurity.com/rsalabs/faq/3-6-6.html for more information
about md5. about md5.
""" """
irc.reply(utils.crypt.md5(text).hexdigest()) irc.reply(utils.crypt.md5(text.encode('utf8')).hexdigest())
md5 = wrap(md5, ['text']) md5 = wrap(md5, ['text'])
@internationalizeDocstring @internationalizeDocstring

View File

@ -98,6 +98,10 @@ class StringTestCase(PluginTestCase):
i = ord(c) i = ord(c)
self.assertResponse('ord %s' % utils.str.dqrepr(c), str(i)) self.assertResponse('ord %s' % utils.str.dqrepr(c), str(i))
def testMd5(self):
self.assertResponse('md5 supybot', '630f4afcfb53c9e84c0a95064bd6add3')
def testEncodeDecode(self): def testEncodeDecode(self):
# This no longer works correctly. It almost seems like were throwing # This no longer works correctly. It almost seems like were throwing
# in a repr() somewhere. # in a repr() somewhere.

View File

@ -60,7 +60,8 @@ def loadPluginModule(name, ignoreDeprecation=False):
module = imp.load_module(name, *moduleInfo) module = imp.load_module(name, *moduleInfo)
except: except:
sys.modules.pop(name, None) sys.modules.pop(name, None)
for key in sys.modules: keys = sys.modules.keys()
for key in keys:
if key.startswith(name + '.'): if key.startswith(name + '.'):
sys.modules.pop(key) sys.modules.pop(key)
raise raise