Skip to content

hex(bitfield) throws exception if __setitem__ was given a bitfield #1

@Notgnoshi

Description

@Notgnoshi
diff --git a/bitfield.py b/bitfield.py
index 229b473..21aa646 100644
--- a/bitfield.py
+++ b/bitfield.py
@@ -161,6 +161,8 @@ class Bitfield(object):
         '0b0'
         """
         length = len(self)
+        if isinstance(value, __class__):
+            value = value.value
         if isinstance(key, int):
             if key >= length or key < -length:
                 raise IndexError("Bitfield index out of range")
b = Bitfield(0x0, width=16)
b1 = Bitfield(0x7, width=8)
b2 = Bitfield(0xa1, width=8)
b[0:8] = b1
b[8:16] = b2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions