Fix for named values of BITS used via types #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a bugfix for an actual pysmi code generation problem that I ran into. Summarizing by example, the following (simplified) construction:
...is parsed properly and makes available bitZero(0) and bitOne(1) for enumeration via
someObject.getSyntax().namedValues
, as it should. However, the following (effectively equivalent) alternative:...is also parsed properly, but does not make available bitZero(0) and bitOne(1) for enumeration via
someObject.getSyntax().namedValues
, nor in any other way for that matter. Such uses of types with BITS syntax are just as valid as using BITS directly, and so I can only conclude that this behavior is not intended. This issue seems to have been present since at least pysmi's switch to the use of a Jinja2 template. The problem is fortunately also limited to that template.The attached fix addresses the problem, thus ensuring that the bit values also end up in
namedValues
in the second case. I have used my test script from PR #3 to ensure that this fix does not break anything in the mibs.pysnmp.com collection: the exact same statistics come out before and after. However, from that collection, 292 modules end up with additional named-values lists as a result of this fix, and I believe it is therefore purely an improvement for any users of those MIBs.