Closed mgorny closed 1 year ago
@mgorny before having a closer look:
@mgorny before having a closer look:
* Which versions of VCR.py are known affected or not affected, what did you use and try?
5.1.0 failed, 5.0.0 passed.
* Is there a related ticket In Gentoo that I just failed to find?
No, I noticed while bumping, so I deselected it.
Bisect says it's 4f70152e7ce510cde41cf071585cbdb481e4e8f2 (CC @jairhenrique):
commit 4f70152e7ce510cde41cf071585cbdb481e4e8f2 (HEAD)
Author: Jair Henrique <jair.henrique@gmail.com>
AuthorDate: 2023-06-27 14:12:40 +0200
Commit: Jair Henrique <jair.henrique@gmail.com>
CommitDate: 2023-06-27 22:36:26 +0200
Enable rule B (flake8-bugbear) on ruff
Prior to this change, the exception is:
ValueError: 'utf-8' codec can't decode byte 0x45 in position 0: invalid start byteDoes this HTTP interaction contain binary data? If so, use a different serializer (like the yaml serializer) for this request?
After it, it is:
ValueError: 'utf-8' codec can't decode byte 0x8c in position 0: invalid start byte
Without simplejson
installed, it is:
ValueError: Does this HTTP interaction contain binary data? If so, use a different serializer (like the yaml serializer) for this request?
Perhaps the simplest solution would be to remove simplejson
support entirely — I suspect it's only there for py2 support.
Oh, and my educated guess is that this is the problematic part of the change:
diff --git a/vcr/serializers/jsonserializer.py b/vcr/serializers/jsonserializer.py
index 5ffef3e..55cf780 100644
--- a/vcr/serializers/jsonserializer.py
+++ b/vcr/serializers/jsonserializer.py
@@ -17,13 +17,5 @@ def serialize(cassette_dict):
try:
return json.dumps(cassette_dict, indent=4) + "\n"
- except UnicodeDecodeError as original: # py2
- raise UnicodeDecodeError(
- original.encoding,
- b"Error serializing cassette to JSON",
- original.start,
- original.end,
- original.args[-1] + error_message,
- )
- except TypeError: # py3
- raise TypeError(error_message)
+ except TypeError:
+ raise TypeError(error_message) from None
Note that it removes exception rewriting for "py2" case, and I guess simplejson
falls into that case.
@mgorny thanks for the additional details! :pray:
Thanks!
When
simplejson
is installed in the system, it is used over the built-injson
module. This causes the following test to fail: