Skip to content

Fix the return value of Restreamed._build.#1119

Open
rurik-supermassive wants to merge 1 commit intoconstruct:masterfrom
supermassive-tech:restreamed_fix
Open

Fix the return value of Restreamed._build.#1119
rurik-supermassive wants to merge 1 commit intoconstruct:masterfrom
supermassive-tech:restreamed_fix

Conversation

@rurik-supermassive
Copy link

Similar to Transformed._build, it now correctly returns the output of its subcon build.

Before this commit using Restreamed would fail when accessing the context as in the following example:

RestreamedPassthrough = lambda subcon: Restreamed(subcon, lambda b: b, 1, lambda b: b, 1, lambda n: n)

x = Struct(a=RestreamedPassthrough(Const(1, Byte)), b=Rebuild(Byte, this.a))
x.build({})

In the Rebuild context a was not populated and was None. With this fix it is correctly populated with the built context of the sub-construct.

Similar to `Transformed._build`, it now correctly returns the output of its `subcon` build.

Before this commit using `Restreamed` would fail when accessing the context as in the
following example:

```python
RestreamedPassthrough = lambda subcon: Restreamed(subcon, lambda b: b, 1, lambda b: b, 1, lambda n: n)

x = Struct(a=RestreamedPassthrough(Const(1, Byte)), b=Rebuild(Byte, this.a))
x.build({})
```

In the `Rebuild` context `a` was not populated and was `None`. With this fix it is correctly
populated with the built context of the sub-construct.
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