Skip to content

Support subclasses of bytearray too in Bytes and GreedyBytes - #1191

Open
matthijskooijman wants to merge 2 commits into
construct:masterfrom
matthijskooijman:support-bytearray-subclasses
Open

matthijskooijman wants to merge 2 commits into
construct:masterfrom
matthijskooijman:support-bytearray-subclasses

Conversation

@matthijskooijman

Copy link
Copy Markdown

Bytes and Greedybytes accepted bytarray instances Since commit 8d76dfb (Bytes* fixed (allows to build from bytearrays) per #827, 2020-01-21), but did not use instanceof to check so would not accept bytearray subclasses. From the commit, there does not seem to be any particular reason for this, so this changes from an exact type match to using instanceof.

Bytes and Greedybytes accepted bytarray instances Since commit 8d76dfb
(Bytes* fixed (allows to build from bytearrays) per construct#827, 2020-01-21),
but did not use instanceof to check so would not accept bytearray
subclasses. From the commit, there does not seem to be any particular
reason for this, so this changes from an exact type match to using
instanceof.
Without an explicit subcon, Const would default to Bytes. It would then
insist the value passed is a bytes, even though Bytes also accepts a
bytearray. So also accept bytearray here.
@matthijskooijman

Copy link
Copy Markdown
Author

Just pushed one additional commit that lets Const also accept bytearray values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant