Closed dominicdoty closed 1 year ago
ran test pipelines on my fork, all passed:
https://github.com/dominicdoty/pyjson_tricks/actions/runs/3365444659
Thanks for providing a solution! I think I'll make some slight changes, because I'd prefer to handle this when encoding instead of decoding.
I figured it maybe is a valid thing to encode and then confirm that the new object has the same attribute, since you potentially could have different behavior if someone changed the class definition to not include the __weakref__
attribute before decoding in a different environment.
But, that's probably too much of a corner case to care about.
If anyone finds this in the future because they have some jsons with this encoded in already - you can simply delete the __weakref__
attribute from your json to fix it.
Definitely something to be said for having json debug-able, and for supporting existing exports.
But in this case I think I prefer more strongly to have the json as clean as possible, and not require weakrefs to be encode-able.
Works for me!
Thanks for taking care of this, glad to have it fixed either way.
Fix for #82
Tests passing in Python 3.7.9