Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
LazyStruct and LazySequence don't use kwargs #365
When using the Python 3.6+ keyword argument syntax to build constructs, building lazy constructs fails.
from construct import Struct, LazyStruct, Byte MY_STRUCT_NON_KW = Struct( "a" / Byte, "b" / Byte, "c" / Byte, "d" / Byte, ) MY_LAZY_STRUCT_NON_KW = LazyStruct( "a" / Byte, "b" / Byte, "c" / Byte, "d" / Byte, ) MY_STRUCT = Struct(a=Byte, b=Byte, c=Byte, d=Byte) MY_LAZY_STRUCT = LazyStruct(a=Byte, b=Byte, c=Byte, d=Byte) print("MY_STRUCT_NON_KW:", MY_STRUCT_NON_KW.parse(b'\x00\x00\x00\x00')) print("MY_LAZY_STRUCT_NON_KW:", MY_LAZY_STRUCT_NON_KW.parse(b'\x00\x00\x00\x00')) print("MY_STRUCT:", MY_STRUCT.parse(b'\x00\x00\x00\x00')) print("MY_LAZY_STRUCT:", MY_LAZY_STRUCT.parse(b'\x00\x00\x00\x00'))
I would have expected the lazy versions to produce the same values as the non-lazy versions.
Credits: Discovered with help from pylint
When I opened the construct code in my editor, the linters raised some interesting warnings, including this one: "Unused argument kw". I then investigated and found that it was actually a bug and reported it.
Most of the credit belongs to pylint.