Hello, I looked for a bit but was unable to find anything related to this.
I have this code snippet :
from construct import *
b1 = IfThenElse(lambda ctx: ctx._params.get('ctx') == 1, Int8ul, Int16ul)
a = Struct(
"1" / Int8ul,
"2" / Select(b1, Bit)
)
context = {"ctx": 1}
b = a.build({"1": 1, "2": 2}, **context)
print(len(b)) # Output: 3
I would expect to have the length of b to be 2 as my ctx provided is 1 but not it goes to the else part of the IfThenElse statement.
The behavior is correct when I remove the Select.
Hello, I looked for a bit but was unable to find anything related to this.
I have this code snippet :
I would expect to have the length of
bto be 2 as my ctx provided is 1 but not it goes to the else part of theIfThenElsestatement.The behavior is correct when I remove the
Select.