decoder/helpers: use globals() with exception
authorDmitry Selyutin <dmitry.selyutin@3mdeb.com>
Wed, 29 Sep 2021 11:44:52 +0000 (11:44 +0000)
committerDmitry Selyutin <dmitry.selyutin@3mdeb.com>
Wed, 29 Sep 2021 19:32:54 +0000 (19:32 +0000)
src/openpower/decoder/helpers.py

index 84300ba0d92367d98b5ceb4a0a6f8e993056e2a8..a11081bc2478fefe8e38a4fddb303a3dc4bea608 100644 (file)
@@ -458,7 +458,10 @@ class ISACallerHelper:
         return SelectableInt(value.value & ((1 << bits) - 1), self.XLEN)
 
     def __getattr__(self, attr):
-        return getattr(sys.modules[ISACallerHelper.__module__], attr)
+        try:
+            return globals()[attr]
+        except KeyError:
+            raise AttributeError(attr)
 
 
 if __name__ == '__main__':