From c702aa361aee4c49e162e03b1e94ab732475ee43 Mon Sep 17 00:00:00 2001 From: yanghuichan Date: Mon, 7 Aug 2017 14:19:36 +0800 Subject: [PATCH] Replace dict.iteritems() with dict.items() in keystone 1.As mentioned in [1], we should avoid using dict.iteritems to achieve iterators. We can use dict.items instead, as it will return iterators in PY3 as well. And dict.items will more readable. 2.In py2, the performance about list should be negligible, see the link [2]. [1] https://wiki.openstack.org/wiki/Python3#Common_patterns [2] http://lists.openstack.org/pipermail/openstack-dev/2015-June/066391.html Change-Id: I7363b807f2f8ce7da09403985939583966e000de --- keystone/common/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/keystone/common/utils.py b/keystone/common/utils.py index 794fd60ec4..0a15b8b0c6 100644 --- a/keystone/common/utils.py +++ b/keystone/common/utils.py @@ -95,8 +95,8 @@ class SmarterEncoder(jsonutils.json.JSONEncoder): """Help for JSON encoding dict-like objects.""" def default(self, obj): - if not isinstance(obj, dict) and hasattr(obj, 'iteritems'): - return dict(obj.iteritems()) + if not isinstance(obj, dict) and hasattr(obj, 'items'): + return dict(obj.items()) return super(SmarterEncoder, self).default(obj)