-
Notifications
You must be signed in to change notification settings - Fork 375
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
JSON serializer can't serialize binary data: UnicodeDecodeError: 'utf8' error #51
Comments
yeah looks like it's having trouble serializing the binary data. |
Any plan on a fix for this issue |
Sorry, I've been really busy and haven't had a chance to check it out. Do you have the same problem with the yaml serializer?
|
It looks like the problem is that JSON can't serialize binary data. The response contains the binary zip file, which can't be encoded into UTF-8. I'm not sure what the solution here is. I could base64 encode the response string, but that would break backwards compatibility with old JSON cassettes as well as defeat the ability to open the cassette file to inspect the response for debugging purposes. |
Sorry forgot to mention, it does work with yaml |
Any updates on this issue - I'm having the same issue and would prefer to use json over yaml for the serializer due to performance issues loading in the yaml file. |
Maybe a new serializer: base64-encoded json??? For the yaml performance issue - make sure you are using the libyaml c bindings instead of falling back to the pure python implementation - it’s a lot faster. |
When I try to upload or download a .zip file, i see the above error, If i make a plain requests call it works , but with vcr I see the above error
Guess this is happening while serialising the content , with this error the cassette never gets created
Here is the stack -
File "/Library/Python/2.7/site-packages/vcr/cassette.py", line 127, in exit
self._save()
File "/Library/Python/2.7/site-packages/vcr/cassette.py", line 88, in _save
serializer=self._serializer
File "/Library/Python/2.7/site-packages/vcr/persist.py", line 10, in save_cassette
data = serializer.serialize(cassette_dict)
File "/Library/Python/2.7/site-packages/vcr/serializers/jsonserializer.py", line 34, in serialize
return json.dumps(data, indent=4, default=_json_default)
File "/Library/Python/2.7/site-packages/simplejson/init.py", line 369, in dumps
**kw).encode(obj)
File "/Library/Python/2.7/site-packages/simplejson/encoder.py", line 264, in encode
chunks = list(chunks)
File "/Library/Python/2.7/site-packages/simplejson/encoder.py", line 600, in _iterencode
for chunk in _iterencode_list(o, _current_indent_level):
File "/Library/Python/2.7/site-packages/simplejson/encoder.py", line 455, in _iterencode_list
for chunk in chunks:
File "/Library/Python/2.7/site-packages/simplejson/encoder.py", line 568, in _iterencode_dict
for chunk in chunks:
File "/Library/Python/2.7/site-packages/simplejson/encoder.py", line 568, in _iterencode_dict
for chunk in chunks:
File "/Library/Python/2.7/site-packages/simplejson/encoder.py", line 535, in _iterencode_dict
yield _encoder(value)
The text was updated successfully, but these errors were encountered: