From b460581e8ab37f7d3aa1f1a154e5e67b96fc3585 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 16 Nov 2012 20:39:21 -0500 Subject: Use iitems() to avoid lists of dict items on py2. --- coverage/backward.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'coverage/backward.py') diff --git a/coverage/backward.py b/coverage/backward.py index b78158c..6347501 100644 --- a/coverage/backward.py +++ b/coverage/backward.py @@ -49,6 +49,16 @@ try: except NameError: range = range +# A function to iterate listlessly over a dict's items. +if "iteritems" in dir({}): + def iitems(d): + """Produce the items from dict `d`.""" + return d.iteritems() +else: + def iitems(d): + """Produce the items from dict `d`.""" + return d.items() + # Exec is a statement in Py2, a function in Py3 if sys.version_info >= (3, 0): def exec_code_object(code, global_map): -- cgit v1.2.1