python: Replace DictMixin with Mapping / MutableMapping
authorAndreas Sandberg <andreas.sandberg@arm.com>
Fri, 25 Jan 2019 12:00:20 +0000 (12:00 +0000)
committerAndreas Sandberg <andreas.sandberg@arm.com>
Tue, 12 Feb 2019 17:06:35 +0000 (17:06 +0000)
Python 3 has removed support for DictMixin, so switch to Mapping /
MutableMapping in collections which provides the same functionality.

Change-Id: I61fbe366d2c9fc6e01b470f82f49cc02b99dec32
Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/15984
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
src/python/m5/debug.py

index f7e34a7286f2818ed3d55a3ced4993aa89b6d120..d2892f7e3b770d96773ab19eb53404c50de154fd 100644 (file)
@@ -28,7 +28,7 @@
 
 from __future__ import print_function
 
-from UserDict import DictMixin
+from collections import Mapping
 
 import _m5.debug
 from _m5.debug import SimpleFlag, CompoundFlag
@@ -56,7 +56,7 @@ def help():
             printList([ c.name() for c in children ], indent=8)
     print()
 
-class AllFlags(DictMixin):
+class AllFlags(Mapping):
     def __init__(self):
         self._version = -1
         self._dict = {}
@@ -79,6 +79,14 @@ class AllFlags(DictMixin):
         self._update()
         return self._dict[item]
 
+    def __iter__(self):
+        self._update()
+        return iter(self._dict)
+
+    def __len__(self):
+        self._update()
+        return len(self._dict)
+
     def keys(self):
         self._update()
         return self._dict.keys()
@@ -91,16 +99,4 @@ class AllFlags(DictMixin):
         self._update()
         return self._dict.items()
 
-    def iterkeys(self):
-        self._update()
-        return self._dict.iterkeys()
-
-    def itervalues(self):
-        self._update()
-        return self._dict.itervalues()
-
-    def iteritems(self):
-        self._update()
-        return self._dict.iteritems()
-
 flags = AllFlags()