power_fields: support assignment to same class instance
authorDmitry Selyutin <ghostmansd@gmail.com>
Fri, 6 Jan 2023 17:22:53 +0000 (20:22 +0300)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 2 Jun 2023 18:51:16 +0000 (19:51 +0100)
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))