You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I tried to cache API responses, it failed as sometimes I have UnicodeDecodeError.
Looking deeper, I found that this is happening because of this code out.write_string(cPickle.dumps(obj, 0).decode("utf-8")) in PythonObjectSerializer
Full Code:
The issue here is the default serialiser can't handle special characters e.g. ä (\u00e4) and raises PythonObjectSerializer. The workaround is to use json.dumps serialisation that does handle it, but this is merely a workaround, which is the same as examples (df.to_json()).
I get it, that using pickle.dumps means you can pickle any Python object (that may not be JSON serialisable), if that is the intention please add support for non English characters.
In general using pickle for serialisation is a bad idea. For example see data protocols (here) so python versions need to match, and there are no guarantees of backwards compatibility. Moreover, as pickle doc says at the top The pickle module is not secure. Only unpickle data you trust. clearly clients can can deserialise data stored by other clients in hazelcast, which makes it a path for malicious code execution.
Good time of the day team
When I tried to cache API responses, it failed as sometimes I have UnicodeDecodeError.
Looking deeper, I found that this is happening because of this code
out.write_string(cPickle.dumps(obj, 0).decode("utf-8"))
inPythonObjectSerializer
Full Code:
Issue example:
As a workaround, I created such a custom serializer:
Is there any better solution?
python version: 3.6
The text was updated successfully, but these errors were encountered: