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

pickler: create copies of seen objects #338

Merged
merged 2 commits into from Jan 15, 2021
Merged

Conversation

davvid
Copy link
Member

@davvid davvid commented Jan 14, 2021

Previously the make_refs=False / unpicklable=False code path
would avoid emitting data for objects it had already seen.
It mostly did this to avoid cycles, as its reference
system is disabled in these modes, and thus the result
was that null was emitted for any objects that appear
more than once in the object graph.

Improve the behavior by keeping track of objects that we
have already flattened and simply return the pre-flattened
representation when we re-encounter the same object.

This is a simple solution that fixes encoding of datetime
objects with UTC tzinfo in these scenarios.

Resolves #333 #334 #337
Signed-off-by: David Aguilar davvid@gmail.com

Previously the make_refs=False / unpicklable=False code path
would avoid emitting data for objects it had already seen.
It mostly did this to avoid cycles, as its reference
system is disabled in these modes. The end result was that null
was emitted for any objects that appear more than once in the
object graph.

Improve the behavior by keeping track of objects that we
have already flattened and return the pre-flattened
representation when we re-encounter the same object.

This is a simple solution that fixes encoding of datetime
objects with UTC tzinfo in these scenarios.  It also improves
encoding of objects with multiple references to the same
object as the object will now be properly encoded each
time it is encountered in the object graph.

Resolves jsonpickle#333 jsonpickle#334 jsonpickle#337
Signed-off-by: David Aguilar <davvid@gmail.com>
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.

make_refs=False Not working as expected or breaking the _in_cycle
1 participant