power_fields: support assignment to same class instance
authorDmitry Selyutin <ghostmansd@gmail.com>
Fri, 6 Jan 2023 17:22:53 +0000 (20:22 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Sun, 15 Jan 2023 19:47:22 +0000 (22:47 +0300)
src/openpower/decoder/power_fields.py

index 856182f36de8e918c92418196d5a129a2869d5ef..b0f179099f3aa01036a7a760e7b4594bb40c3f9b 100644 (file)
@@ -102,7 +102,8 @@ class Reference:
             bits = range(bits.start, bits.stop)
         bits = tuple(bits)
 
-        if isinstance(value, int):
+        if isinstance(value, (int, self.__class__)):
+            value = int(value)
             if value.bit_length() > len(bits):
                 raise OverflowError(value)
             value = _SelectableInt(value=value, bits=len(bits))