Prevent 'dictionary changed size during iteration'.

This commit is contained in:
Valentin Lorentz 2015-09-02 15:00:20 +00:00
parent 1c218592af
commit 17b1ae2dd5
1 changed files with 4 additions and 4 deletions

View File

@ -406,7 +406,7 @@ class IrcChannel(object):
"""Checks whether a given hostmask is banned by the channel banlist.""" """Checks whether a given hostmask is banned by the channel banlist."""
assert ircutils.isUserHostmask(hostmask), 'got %s' % hostmask assert ircutils.isUserHostmask(hostmask), 'got %s' % hostmask
now = time.time() now = time.time()
for (pattern, expiration) in self.bans.items(): for (pattern, expiration) in list(self.bans.items()):
if now < expiration or not expiration: if now < expiration or not expiration:
if ircutils.hostmaskPatternEqual(pattern, hostmask): if ircutils.hostmaskPatternEqual(pattern, hostmask):
return True return True
@ -460,7 +460,7 @@ class IrcChannel(object):
if self.checkBan(hostmask): if self.checkBan(hostmask):
return True return True
now = time.time() now = time.time()
for (pattern, expiration) in self.ignores.items(): for (pattern, expiration) in list(self.ignores.items()):
if now < expiration or not expiration: if now < expiration or not expiration:
if ircutils.hostmaskPatternEqual(pattern, hostmask): if ircutils.hostmaskPatternEqual(pattern, hostmask):
return True return True
@ -803,7 +803,7 @@ class UsersDictionary(utils.IterableMap):
del self._nameCache[self._nameCache[id]] del self._nameCache[self._nameCache[id]]
del self._nameCache[id] del self._nameCache[id]
if id in self._hostmaskCache: if id in self._hostmaskCache:
for hostmask in self._hostmaskCache[id]: for hostmask in list(self._hostmaskCache[id]):
del self._hostmaskCache[hostmask] del self._hostmaskCache[hostmask]
del self._hostmaskCache[id] del self._hostmaskCache[id]
self.flush() self.flush()
@ -950,7 +950,7 @@ class IgnoresDB(object):
def checkIgnored(self, prefix): def checkIgnored(self, prefix):
now = time.time() now = time.time()
for (hostmask, expiration) in self.hostmasks.items(): for (hostmask, expiration) in list(self.hostmasks.items()):
if expiration and now > expiration: if expiration and now > expiration:
del self.hostmasks[hostmask] del self.hostmasks[hostmask]
else: else: