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

Fix infinite recursion in __repr__ #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

trendels
Copy link
Contributor

@trendels trendels commented Oct 2, 2020

The auto-generated __repr__ for inspected objects currently does not work because a lot of objects contain circular references (for example index <-> constraint) which leads to infinite recursion.

This PR adds a fix for this by keeping track of which objects have already been visited during a call to __repr__ and returning '...' for recursive references instead of resolving them. I've shamelessly stolen the technique from the popular "attrs" library: https://github.com/python-attrs/attrs/blob/f680c5b83e65413eeb684c68ece60198015058c3/src/attr/_make.py#L1643

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

Successfully merging this pull request may close these issues.

None yet

1 participant