Skip to content

Dictionary iteration error when dealing with subgraphs #452

@herronelou

Description

@herronelou

Hello,

I found an issue with expanding graphs:

for grp_node_id, grp_sub_graph in self.sub_graphs.items():

At this line 👆 you iterate though the items of an internal dict.
A few lines lower, within the iteration there is this call: 👇

self.collapse_group_node(grp_node)

However, the function called from there 👆 is modifying the same internal dict 👇

sub_graph = self.sub_graphs.pop(node.id, None)

As a result, it raises RuntimeError: dictionary changed size during iteration

This is likely a result of a Python2 to Python3 change, where the result of dict.items() changed from a list to an iterator.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions