From 7d71f6641fcb660de0f003e2c028b464d7116ca1 Mon Sep 17 00:00:00 2001 From: Andreas Sandberg Date: Sat, 26 Jan 2019 09:19:22 +0000 Subject: python: Make iterator handling Python 3 compatible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Many functions that used to return lists (e.g., dict.items()) now return iterators and their iterator counterparts (e.g., dict.iteritems()) have been removed. Switch calls to the Python 2.7 iterator methods to use the Python 3 equivalent and add explicit list conversions where necessary. Change-Id: I0c18114955af8f4932d81fb689a0adb939dafaba Signed-off-by: Andreas Sandberg Reviewed-on: https://gem5-review.googlesource.com/c/15992 Reviewed-by: Juha Jäykkä Reviewed-by: Jason Lowe-Power --- src/python/m5/params.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/python/m5/params.py') diff --git a/src/python/m5/params.py b/src/python/m5/params.py index 0c189c983..729fc1242 100644 --- a/src/python/m5/params.py +++ b/src/python/m5/params.py @@ -904,7 +904,7 @@ class Bool(ParamValue): code('%s to_bool(%s, %s);' % (ret, src, dest)) def IncEthernetAddr(addr, val = 1): - bytes = map(lambda x: int(x, 16), addr.split(':')) + bytes = [ int(x, 16) for x in addr.split(':') ] bytes[5] += val for i in (5, 4, 3, 2, 1): val,rem = divmod(bytes[i], 256) @@ -1282,7 +1282,7 @@ class MetaEnum(MetaParamValue): raise TypeError("Enum-derived class attribute 'map' " \ "must be of type dict") # build list of value strings from map - cls.vals = cls.map.keys() + cls.vals = list(cls.map.keys()) cls.vals.sort() elif 'vals' in init_dict: if not isinstance(cls.vals, list): @@ -1453,7 +1453,7 @@ class Enum(ParamValue): @classmethod def cxx_ini_parse(cls, code, src, dest, ret): code('if (false) {') - for elem_name in cls.map.iterkeys(): + for elem_name in cls.map.keys(): code('} else if (%s == "%s") {' % (src, elem_name)) code.indent() code('%s = Enums::%s;' % (dest, elem_name)) -- cgit v1.2.3