Use six.iteritems to make dict work on Python2/3

six.iteritems returns an iterator over dictionary‘s items.
This replaces dictionary.iteritems() on Python 2 and dictionary.items()
on Python 3. See http://pythonhosted.org/six/#six.iteritems

Part of blueprint py33
Change-Id: I72ef4e2ab6944e58069f9476b2e6dca10c9c94aa
This commit is contained in:
Eric Guo
2014-01-10 22:41:54 +08:00
parent 70ef2252bc
commit 3aeff452af
13 changed files with 44 additions and 25 deletions

View File

@@ -16,6 +16,7 @@
import re
import memcache
import six
from stackalytics.openstack.common import log as logging
from stackalytics.processor import utils
@@ -111,7 +112,7 @@ class MemcachedStorage(RuntimeStorage):
original = self.memcached.get(self._get_record_name(record_id))
need_update = False
for field, value in correction.iteritems():
for field, value in six.iteritems(correction):
if (field not in original) or (original[field] != value):
need_update = True
original[field] = value