[diffoscope] 01/05: comparators.json: fix UnicodeDecodeError with a non-UTF8 locale.
Mattia Rizzolo
mattia at debian.org
Wed Feb 28 21:07:51 CET 2018
This is an automated email from the git hooks/post-receive script.
mattia pushed a commit to branch master
in repository diffoscope.
commit 7b8998e571efca414c395644f6f9162b81b4272f
Author: Mattia Rizzolo <mattia at debian.org>
Date: Wed Feb 28 20:24:58 2018 +0100
comparators.json: fix UnicodeDecodeError with a non-UTF8 locale.
Signed-off-by: Mattia Rizzolo <mattia at debian.org>
---
diffoscope/comparators/json.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/diffoscope/comparators/json.py b/diffoscope/comparators/json.py
index 06da4ed..17808ec 100644
--- a/diffoscope/comparators/json.py
+++ b/diffoscope/comparators/json.py
@@ -33,7 +33,7 @@ except ImportError: # noqa
class JSONFile(File):
@classmethod
def recognizes(cls, file):
- with open(file.path) as f:
+ with open(file.path, 'rb') as f:
# Try fuzzy matching for JSON files
is_text = any(
file.magic_file_type.startswith(x)
@@ -41,7 +41,7 @@ class JSONFile(File):
)
if is_text and not file.name.endswith('.json'):
buf = f.read(10)
- if not any(x in buf for x in '{['):
+ if not any(x in buf for x in b'{['):
return False
f.seek(0)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the diffoscope
mailing list