Iterate over a copy of the channel keys
In Python 2, dict.keys() created a list copy of a dictionary's keys, but in Python 3 it's an iterable tied to the original dict instead. Modifying the data dict while iterating over its keys under Python 3 therefore causes items to get removed out from under the loop before they're reached. Switch to using an explicit list copy instead for iteration, and similarly save the result as an explicit list rather than carrying over the iterable. Change-Id: Iac96cdf3bab47071f197832172b94481e7bf00d5
This commit is contained in:
parent
df6af38172
commit
04a8d696f1
|
@ -401,11 +401,11 @@ class GerritMQTT(Gerrit):
|
|||
class ChannelConfig(object):
|
||||
def __init__(self, data):
|
||||
self.data = data
|
||||
keys = data.keys()
|
||||
keys = list(data.keys())
|
||||
for key in keys:
|
||||
if key[0] != '#':
|
||||
data['#' + key] = data.pop(key)
|
||||
self.channels = data.keys()
|
||||
self.channels = list(data.keys())
|
||||
self.projects = {}
|
||||
self.events = {}
|
||||
self.branches = {}
|
||||
|
|
Loading…
Reference in New Issue