Skip to content

RuntimeError: dictionary changed size during iteration #309

@htruscott

Description

@htruscott

Runtime error in ParserDispatchMixin._iter_class_members on the latest main branch (traceback below). Doesn't happen on v2.5.5. Module is pyrosetta, see https://www.pyrosetta.org/downloads#h.yscr0432xlk9.

Debugging shows the class whose dict is changing is pyrosetta.distributed.utility.log.LoggerMixin, which is not a pybind(ed) class. getattr() is probably changing the dict. Simple fix would be just read out the class members first then iterate, which I will PR.

Command:

pybind11-stubgen -o "pyrosetta_stubs_latest" pyrosetta --ignore-all-errors

Traceback:

Traceback (most recent call last):
  File "/home/miner/.conda/envs/pyrosetta_release/bin/pybind11-stubgen", line 6, in <module>
    sys.exit(main())
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/__init__.py", line 330, in main
    run(
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/__init__.py", line 370, in run
    module = parser.handle_module(
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/error_handlers.py", line 45, in handle_module
    return super().handle_module(path, module)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/fix.py", line 216, in handle_module
    result = super().handle_module(path, module)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/fix.py", line 232, in handle_module
    result = super().handle_module(path, module)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/fix.py", line 130, in handle_module
    result = super().handle_module(path, module)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/fix.py", line 499, in handle_module
    result = super().handle_module(path, module)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/parse.py", line 118, in handle_module
    obj = self.handle_module_member(
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/filter.py", line 123, in handle_module_member
    return super().handle_module_member(path, module, obj)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/filter.py", line 140, in handle_module_member
    result = super().handle_module_member(path, module, obj)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/parse.py", line 182, in handle_module_member
    return self.handle_module(path, member)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/error_handlers.py", line 45, in handle_module
    return super().handle_module(path, module)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/fix.py", line 216, in handle_module
    result = super().handle_module(path, module)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/fix.py", line 232, in handle_module
    result = super().handle_module(path, module)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/fix.py", line 130, in handle_module
    result = super().handle_module(path, module)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/fix.py", line 499, in handle_module
    result = super().handle_module(path, module)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/parse.py", line 118, in handle_module
    obj = self.handle_module_member(
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/filter.py", line 123, in handle_module_member
    return super().handle_module_member(path, module, obj)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/filter.py", line 140, in handle_module_member
    result = super().handle_module_member(path, module, obj)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/parse.py", line 182, in handle_module_member
    return self.handle_module(path, member)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/error_handlers.py", line 45, in handle_module
    return super().handle_module(path, module)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/fix.py", line 216, in handle_module
    result = super().handle_module(path, module)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/fix.py", line 232, in handle_module
    result = super().handle_module(path, module)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/fix.py", line 130, in handle_module
    result = super().handle_module(path, module)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/fix.py", line 499, in handle_module
    result = super().handle_module(path, module)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/parse.py", line 118, in handle_module
    obj = self.handle_module_member(
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/filter.py", line 123, in handle_module_member
    return super().handle_module_member(path, module, obj)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/filter.py", line 140, in handle_module_member
    result = super().handle_module_member(path, module, obj)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/parse.py", line 182, in handle_module_member
    return self.handle_module(path, member)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/error_handlers.py", line 45, in handle_module
    return super().handle_module(path, module)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/fix.py", line 216, in handle_module
    result = super().handle_module(path, module)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/fix.py", line 232, in handle_module
    result = super().handle_module(path, module)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/fix.py", line 130, in handle_module
    result = super().handle_module(path, module)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/fix.py", line 499, in handle_module
    result = super().handle_module(path, module)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/parse.py", line 118, in handle_module
    obj = self.handle_module_member(
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/filter.py", line 123, in handle_module_member
    return super().handle_module_member(path, module, obj)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/filter.py", line 140, in handle_module_member
    result = super().handle_module_member(path, module, obj)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/parse.py", line 180, in handle_module_member
    return self.handle_class(path, member)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/error_handlers.py", line 49, in handle_class
    return super().handle_class(path, class_)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/fix.py", line 112, in handle_class
    result = super().handle_class(path, class_)
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/parse.py", line 52, in handle_class
    for name, member in self._iter_class_members(class_):
  File "pyrosetta_testing/pybind11-stubgen/pybind11_stubgen/parser/mixins/parse.py", line 80, in _iter_class_members
    for name in class_.__dict__:```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions