Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Notgnoshi opened this issue Aug 24, 2021 · 0 comments
Open
Labels

Comments

@Notgnoshi
Copy link
Owner

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
@Notgnoshi Notgnoshi added the bug label Aug 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant