-
Notifications
You must be signed in to change notification settings - Fork 87
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
Correctly handle object cycles in munchify/unmunchify #41
Conversation
Thanks! I have a small request regarding the test(s), and then I'll merge your change. |
Good point! I also added more tests, which resulted in me discovering that tuples were not handled correctly in some cases, which is now fixed. The bug was that if the first object encountered in a cycle was a tuple, it would not be handled correctly. For example, although the object graph of dictX → tupleA → dictX would correctly give you munchX → tupleC → munchX, the object graph dictX → tupleA → dictY → tupleA would incorrectly give you munchX → tupleC → dictY → tupleD → dictY. Now it correctly gives munchX → tupleC → dictY → tupleC. |
munch/__init__.py
Outdated
elif isinstance(x, list): | ||
m.extend(cycle_munchify(v, factory, seen) for v in x) | ||
elif isinstance(x, tuple): | ||
for (mv, v) in zip(m, x): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please give better names to these... Too many variables spread around with single letters is very confusing to follow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is still relevant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be better / good now
LGTM. Thanks for your contribution! |
And thanks for your feedback! 🙂 |
No description provided.