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

Recursion Error in __str__ implementation #10

Open
AJNeufeld opened this issue Oct 6, 2022 · 2 comments
Open

Recursion Error in __str__ implementation #10

AJNeufeld opened this issue Oct 6, 2022 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@AJNeufeld
Copy link

To reproduce, in importCIGREMV.py, add:

o = import_result['topology']['_f71dc9cf-458e-4b79-9c3b-6e3a9b5cd398']
print(str(o))

Result: RecursionError: maximum recursion depth exceeded while getting the str of an object

Can also occur with Terminal objects (where I first noticed it), ConformLoad objects, SvPowerFlow objects and possibly others.

@m-mirz m-mirz added the bug Something isn't working label Oct 13, 2022
martinmoraga added a commit that referenced this issue Oct 14, 2022
Signed-off-by: Moraga <[email protected]>
@martinmoraga
Copy link
Contributor

This problem appears because of the existency of circular dependencies in CIM. For example, each topological node points to a SvVoltage object which points back to the topological node object. When we call the str funcion of the TopologicalNode class, it iterates through all its components and calls their respective str function (for example hier).

This means when we call the function str of the class Topological node, this calls the str function of the SvVoltage class, which calls the str function of TopologicalNode and the program ends in a infinite loop.

One possible solution is to use the repr method instead of the str method (see this branch)

@m-mirz
Copy link
Contributor

m-mirz commented Dec 22, 2022

@martinmoraga @dinkelbachjan Should we fix this in cimgen so that the error does not appear again after generating new code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

4 participants