[Git][reproducible-builds/diffoscope][master] Tidy detection of JSON files due to missing call to File.recognizes that...

Chris Lamb gitlab at salsa.debian.org
Sat Jun 27 15:13:48 UTC 2020



Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
d284b58a by Chris Lamb at 2020-06-27T16:13:35+01:00
Tidy detection of JSON files due to missing call to File.recognizes that checks against the output of file(1) which I think (!) was also causing us to attempt to parse almost every file using json.loads. Whoops.

- - - - -


1 changed file:

- diffoscope/comparators/json.py


Changes:

=====================================
diffoscope/comparators/json.py
=====================================
@@ -38,10 +38,13 @@ except ImportError:  # noqa
 
 class JSONFile(File):
     DESCRIPTION = "JSON files"
-    FILE_TYPE_RE = re.compile(r"JSON data")  # Requires file 5.35+
+    FILE_TYPE_RE = re.compile(r"^JSON data")  # Requires file 5.35+
 
     @classmethod
     def recognizes(cls, file):
+        if not super().recognizes(file):
+            return False
+
         with open(file.path, "rb") as f:
             try:
                 file.parsed = json.loads(



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/d284b58a7bbab7c126ed631e3d4fc805af4a2217

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/d284b58a7bbab7c126ed631e3d4fc805af4a2217
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20200627/dab8e780/attachment.htm>


More information about the rb-commits mailing list