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

RuntimeError when importing an older revision of a YANG file #294

Open
andrjohn opened this issue Apr 28, 2023 · 1 comment
Open

RuntimeError when importing an older revision of a YANG file #294

andrjohn opened this issue Apr 28, 2023 · 1 comment
Assignees

Comments

@andrjohn
Copy link

andrjohn commented Apr 28, 2023

When a YANG file imports another module with a revision date but a newer revision is available in the YANG repository then pyangbind raises a RuntimeError. This is easily reproducible with some trivial YANG files:

(venv)%  pyang --plugindir $PYBINDPLUGIN -f pybind -o binding.py [email protected] 
Traceback (most recent call last):
  File "/Users/anjohnso/Development/cirrus/cirrus-bundles/venv2/bin/pyang", line 580, in <module>
    run()
  File "/Users/anjohnso/Development/cirrus/cirrus-bundles/venv2/bin/pyang", line 549, in run
    emit_obj.emit(ctx, modules, fd)
  File "/Users/anjohnso/Development/cirrus/cirrus-bundles/venv2/lib/python3.10/site-packages/pyangbind/plugin/pybind.py", line 222, in emit
    build_pybind(ctx, modules, fd)
  File "/Users/anjohnso/Development/cirrus/cirrus-bundles/venv2/lib/python3.10/site-packages/pyangbind/plugin/pybind.py", line 406, in build_pybind
    build_identities(ctx, defn['identity'])
  File "/Users/anjohnso/Development/cirrus/cirrus-bundles/venv2/lib/python3.10/site-packages/pyangbind/plugin/pybind.py", line 446, in build_identities
    idstore.build_store_from_definitions(ctx, defnd)
  File "/Users/anjohnso/Development/cirrus/cirrus-bundles/venv2/lib/python3.10/site-packages/pyangbind/helpers/identity.py", line 75, in build_store_from_definitions
    mod_ref_prefixes = module_import_prefixes(ctx)
  File "/Users/anjohnso/Development/cirrus/cirrus-bundles/venv2/lib/python3.10/site-packages/pyangbind/helpers/misc.py", line 24, in module_import_prefixes
    for mod in ctx.modules:
RuntimeError: dictionary changed size during iteration
(venv)% 

[email protected]

module example {
  namespace "urn:example:example";
  prefix ex;

  import common {
    prefix cmn;
    revision-date "2023-04-27";
  }

  revision 2023-04-27;

  leaf name {
    type cmn:identifier;
  }
}

[email protected]

module common {
  namespace "urn:example:common";
  prefix cmn;

  revision 2023-04-27;

  typedef identifier {
    type string;
  }
}

[email protected]

module common {
  namespace "urn:example:common";
  prefix cmn;

  revision 2023-04-28;
  revision 2023-04-27;

  typedef identifier {
    type string;
  }

  typedef value {
    type int16;
  }
}

@JoseIgnacioTamayo
Copy link
Collaborator

Hi there,

I was playing a bit with this issue. I guess I found the reason for the Exception, will come back with some updates after.

@JoseIgnacioTamayo JoseIgnacioTamayo self-assigned this Aug 5, 2024
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

No branches or pull requests

2 participants