-
Notifications
You must be signed in to change notification settings - Fork 197
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
24 bit support #406
24 bit support #406
Conversation
result from the test run:
|
|
||
class Unsigned24(struct.Struct): | ||
def __init__(self, *args, **kwargs): | ||
super().__init__("<L", *args, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm suspecting the Struct class uses some clever logic with new instead of init. Maybe you can use composition instead of inheritance in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the hint. I'll have another look at it. I used Python 3.10. There the tests succeeded...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, apparently they changed something between py 3.10 and 3.12, where they enforce that the derived class has the same signature as the base class. I've changed to the composition approach now, as you suggested. The tests succeed now for 3.10 and 3.12. At least locally...
Unsigned24 was inspired by christiansandberg@659899d, but kept a little simpler. I also added the signed version. Signed-off-by: Greter Raffael <[email protected]>
Signed-off-by: Greter Raffael <[email protected]>
02b0712
to
5c22932
Compare
The unsigned24 part was already added in #267. I took the idea from there, but made it a little simpler. Also I added the signed version and extended the unit tests.