Thanks to @jboyd77 for pointing out this problem, and for the fix (to be proposed via a pull request).
ModSubmodStatement.internal_reset() gets called as a consequence of module.internal_reset() after transforms have executed. It calls Statement.internal_reset(), which deletes all self.i_xxx attributes and then sets self.i_is_validated to False. However (unlike the constructor) it doesn't initialize self.i_is_primary_module.
This causes a crash when (a) using transforms, and (b) the module imports submodules. For example, with this YANG:
module reset-bug {
namespace "urn:reset-bug";
prefix reset-bug;
include reset-bug-base;
}
% pyang reset-bug.yang -t edit
Traceback (most recent call last):
File "/Users/william/Development/pyang/default/bin/pyang", line 580, in <module>
run()
File "/Users/william/Development/pyang/default/bin/pyang", line 468, in run
ctx_validate_and_prune()
File "/Users/william/Development/pyang/default/bin/pyang", line 429, in ctx_validate_and_prune
ctx.validate()
File "/Users/william/Development/pyang/default/pyang/context.py", line 348, in validate
statements.validate_module(self, m)
File "/Users/william/Development/pyang/default/pyang/statements.py", line 414, in validate_module
iterate(module, phase)
File "/Users/william/Development/pyang/default/pyang/statements.py", line 371, in iterate
res = f(ctx, stmt)
File "/Users/william/Development/pyang/default/pyang/statements.py", line 190, in <lambda>
('import', 'module'):lambda ctx, s: v_import_module(ctx, s),
File "/Users/william/Development/pyang/default/pyang/statements.py", line 617, in v_import_module
submodule = add_module(i, stmt.i_is_primary_module)
AttributeError: i_is_primary_module
Thanks to @jboyd77 for pointing out this problem, and for the fix (to be proposed via a pull request).
ModSubmodStatement.internal_reset()
gets called as a consequence ofmodule.internal_reset()
after transforms have executed. It callsStatement.internal_reset()
, which deletes allself.i_xxx
attributes and then setsself.i_is_validated
toFalse
. However (unlike the constructor) it doesn't initializeself.i_is_primary_module
.This causes a crash when (a) using transforms, and (b) the module imports submodules. For example, with this YANG:
...we get this: