[Git][reproducible-builds/diffoscope][master] comparators/deb: Fix matching for .deb archive members. (Closes: #903565)
Chris Lamb
gitlab at salsa.debian.org
Mon Aug 13 08:56:45 CEST 2018
Chris Lamb pushed to branch master at Reproducible Builds / diffoscope
Commits:
8b90ec1a by Alexis Murzeau at 2018-08-13T06:56:30Z
comparators/deb: Fix matching for .deb archive members. (Closes: #903565)
my_members is iterated in DebContainer.perform_fuzzy_matching but is modified
in Container.comparisons.prep_yield which remove the current item from
my_members.
This causes an `RuntimeError: OrderedDict mutated during iteration` error.
This was not detected by the existing `test_deb.test_compare_different_compression`
test as it triggers only when there is more than one file in the .deb file.
(That test use only one file: control.tar.{gz,xz}).
Signed-off-by: Chris Lamb <lamby at debian.org>
- - - - -
5 changed files:
- diffoscope/comparators/deb.py
- diffoscope/comparators/utils/fuzzy.py
- tests/comparators/test_deb.py
- + tests/data/bug903565_1.deb
- + tests/data/bug903565_2.deb
Changes:
=====================================
diffoscope/comparators/deb.py
=====================================
--- a/diffoscope/comparators/deb.py
+++ b/diffoscope/comparators/deb.py
@@ -91,6 +91,11 @@ class DebContainer(LibarchiveContainer):
def perform_fuzzy_matching(self, my_members, other_members):
matched = set()
+
+ # Create local copies because they will be modified by consumer
+ my_members = dict(my_members)
+ other_members = dict(other_members)
+
for name1 in my_members.keys():
main, ext = os.path.splitext(name1)
candidates = [name2 for name2 in other_members.keys() - matched
=====================================
diffoscope/comparators/utils/fuzzy.py
=====================================
--- a/diffoscope/comparators/utils/fuzzy.py
+++ b/diffoscope/comparators/utils/fuzzy.py
@@ -34,7 +34,7 @@ def perform_fuzzy_matching(members1, members2):
if tlsh is None or Config().fuzzy_threshold == 0:
return
already_compared = set()
- # Perform local copies because they will be modified by consumer
+ # Create local copies because they will be modified by consumer
members1 = dict(members1)
members2 = dict(members2)
for name1, (file1, _) in members1.items():
=====================================
tests/comparators/test_deb.py
=====================================
--- a/tests/comparators/test_deb.py
+++ b/tests/comparators/test_deb.py
@@ -134,6 +134,9 @@ bug903391_deb1 = load_fixture('bug903391_1.deb')
bug903391_deb2 = load_fixture('bug903391_2.deb')
bug903401_deb1 = load_fixture('bug903401_1.deb')
bug903401_deb2 = load_fixture('bug903401_2.deb')
+bug903565_deb1 = load_fixture('bug903565_1.deb')
+bug903565_deb2 = load_fixture('bug903565_2.deb')
+
@skip_unless_tools_exist('xz')
@@ -151,3 +154,7 @@ def test_uncompressed_data_tar(bug903401_deb1, bug903401_deb2):
def test_uncompressed_control_tar(bug903391_deb1, bug903391_deb2):
bug903391_deb1.compare(bug903391_deb2)
+
+
+def test_compare_different_compression_multiple_files(bug903565_deb1, bug903565_deb2):
+ bug903565_deb1.compare(bug903565_deb2)
=====================================
tests/data/bug903565_1.deb
=====================================
Binary files /dev/null and b/tests/data/bug903565_1.deb differ
=====================================
tests/data/bug903565_2.deb
=====================================
Binary files /dev/null and b/tests/data/bug903565_2.deb differ
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/commit/8b90ec1a4e0c0c73bb67936e80eb898366b67a6f
--
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/commit/8b90ec1a4e0c0c73bb67936e80eb898366b67a6f
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/20180813/437657e9/attachment.html>
More information about the rb-commits
mailing list