[Git][reproducible-builds/diffoscope][master] Prevent a traceback when comparing a contentful .pyc file with an empty one. (Re: Debian:#1064973)
Chris Lamb (@lamby)
gitlab at salsa.debian.org
Fri Mar 1 16:57:08 UTC 2024
Chris Lamb pushed to branch master at Reproducible Builds / diffoscope
Commits:
c885c24a by Chris Lamb at 2024-03-01T16:56:35+00:00
Prevent a traceback when comparing a contentful .pyc file with an empty one. (Re: Debian:#1064973)
They were being detected as PycFiles via FALLBACK_FILE_EXTENSION_SUFFIX,
but this allowed (valid, it seems!) empty .pyc files to be processed by
code that assumed that the file was non-empty. This patch continues
to detect them as PycFiles but does not attempt in-depth parsing.
- - - - -
1 changed file:
- diffoscope/comparators/python.py
Changes:
=====================================
diffoscope/comparators/python.py
=====================================
@@ -21,6 +21,7 @@ import binascii
import dis
import io
import marshal
+import os
import re
import struct
import time
@@ -66,6 +67,12 @@ def describe_pyc(filename):
def parse_pyc(f):
+ f.seek(0, io.SEEK_END)
+ if f.tell() == 0:
+ yield "type: empty"
+ return
+
+ f.seek(0)
magic = f.read(4)
yield "magic: {}".format(hexlify(magic))
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/c885c24ad4807a0ec20c0cca9572b395812c85d9
--
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/c885c24ad4807a0ec20c0cca9572b395812c85d9
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/20240301/d9fc885a/attachment.htm>
More information about the rb-commits
mailing list