-
Notifications
You must be signed in to change notification settings - Fork 618
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
patch: fix NoneType error for 'visit_Case' function in c_generator.py… #548
base: main
Are you sure you want to change the base?
Conversation
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!
Would it be possible to add a test that triggers this? (fails before the PR, succeeds after)
Yes, I understand My question is - can you add a test to https://github.com/eliben/pycparser/blob/main/tests/test_c_generator.py as part of your PR that triggers this behavior and verifies that the change fixes it |
…e when saving AST as JSON.
I'm sorry for the confusion, but the problem is not with the c_generator.py. The issue lies with the "to_dict" function in c_json.py within the examples folder, which saves None instead of an empty list for the case node type. It appears that tests are not performed for the examples, so I did not add the test you requested. However, if needed, I can add it. |
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.
The PR name should be adjusted also to reflect what it's fixing
@mypalmike can you PTAL?
@@ -116,6 +116,8 @@ def to_dict(node): | |||
for child_attr in child_attrs_of(klass): | |||
if child_attr not in result: | |||
result[child_attr] = None | |||
if result['_nodetype'] == "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.
do an if...else
here?
… when a case is empty by adding none type checker