Skip to content
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

calling _pfp__set_value on a Struct always raises an exception #142

Open
michaelmera opened this issue Aug 11, 2021 · 0 comments · May be fixed by #143
Open

calling _pfp__set_value on a Struct always raises an exception #142

michaelmera opened this issue Aug 11, 2021 · 0 comments · May be fixed by #143
Assignees
Labels
bug needs-triage A fresh user-reported issue that needs triage (i.e. is not a concrete-issue)

Comments

@michaelmera
Copy link

Describe the bug

Calling fields.Struct._pfp__set_value always results in a NameError exception. This is because of a typo in a variable name in this function.

To Reproduce

Here is a test reproducing the error:

    def test_struct_set_value(self):
        dom = self._test_parse_build(
            "abc",
            """
                typedef struct {
                    char first;
                    char second;
                    char third;
                } three_bytes;

                three_bytes bytes;
            """,
        )

        dom.bytes._pfp__set_value([ord("x"), ord("y"), ord("z")])
        self.assertEqual(dom.bytes.first, ord("x"))
        self.assertEqual(dom.bytes.second, ord("y"))
        self.assertEqual(dom.bytes.third, ord("z"))

resulting in the following error:

Traceback (most recent call last):
  File "pfp/tests/test_struct_union_2.py", line 479, in test_struct_set_value
    dom.bytes._pfp__set_value([ord("x"), ord("y"), ord("z")])
  File "pfp/tests/../pfp/fields.py", line 835, in _pfp__set_value
    return modified_watches
NameError: name 'modified_watches' is not defined

Expected Behavior

Calling _pfp__set_value should replace the current struct value with the argument, overwriting the struct's children.

@michaelmera michaelmera added bug needs-triage A fresh user-reported issue that needs triage (i.e. is not a concrete-issue) labels Aug 11, 2021
@michaelmera michaelmera linked a pull request Aug 11, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs-triage A fresh user-reported issue that needs triage (i.e. is not a concrete-issue)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants