Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Error on serialization of custom class - if attr is callable it is assumed its constructor takes no arguments #430
The issue got introduced in 2.0.0b5 by the following diff and is still present in 2.7.1:
While trying to traverse and hence serialize certain objects, it might encounter an object which can't be indexed, calls the exception handler which tests it being callable. If so, it does.
In my scenario the object is a class which constructor requires an argument, which the attr() call doesn't provide. In that case it fails with the following backtrace (version 2.0.0b5):
For reference here a backtrace with version 2.7.1:
Since I'm not fully aware of the intentions of above stated change, it seems rude to suggest reverting that change. However for my very case, it solves the problem.
We needed it for a project I was working on, do you have any other possible solutions? Can I help you figure something else out so that we can both be happy?
Can you provide a test to break it? I completely understand your issue, but it would be great to see an example of it to work from.
referenced this issue
Jul 12, 2016
I don't think that it is intuitive to call a callable unconditionally just because it is callable. Callables should not require explicit serialization handling to avoid being invoked with no arguments.
@alexmorken Instead of adding a feature that allowed you to resolve callables, I'm afraid you locked everyone else into your use case. Other frameworks I have seen only ever resolve callables when they are explicit arguments, not arbitrary data that is being serialized.