Commits (3)
#
# diffoscope: in-depth comparison of files, archives, and directories
#
# Copyright © 2021 Chris Lamb <lamby@debian.org>
# Copyright © 2021‒2022 Chris Lamb <lamby@debian.org>
# Copyright © 2021 Sergei Trofimovich
#
# diffoscope is free software: you can redistribute it and/or modify
......@@ -28,6 +28,7 @@ import types
from diffoscope.difference import Difference
from .missing_file import MissingFile
from .utils.file import File
re_memory_address = re.compile(r" at 0x\w+(?=, )")
......@@ -38,6 +39,9 @@ class PycFile(File):
FILE_TYPE_RE = re.compile(r"^python .*byte-compiled$")
def compare_details(self, other, source=None):
if isinstance(other, MissingFile):
return []
try:
return [
Difference.from_text(
......@@ -49,7 +53,7 @@ class PycFile(File):
)
]
except ValueError as exc:
self.add_comment("Could not decombile bytecode: {}".format(exc))
self.add_comment("Could not decompile bytecode: {}".format(exc))
return []
......
#
# diffoscope: in-depth comparison of files, archives, and directories
#
# Copyright © 2021 Chris Lamb <lamby@debian.org>
# Copyright © 2021—2022 Chris Lamb <lamby@debian.org>
#
# diffoscope is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -22,6 +22,7 @@ import sys
from diffoscope.comparators.python import PycFile
from ..utils.data import assert_diff_startswith, load_fixture
from ..utils.nonexisting import assert_non_existing
from ..utils.tools import (
skipif,
skip_unless_file_version_is_at_least,
......@@ -60,3 +61,9 @@ def test_diff(differences):
differences[0],
"pyc_expected_diff",
)
def test_compare_non_existing(monkeypatch, pyc1):
assert_non_existing(
monkeypatch, pyc1, has_details=False, has_null_source=False
)