From f230ed545f832f8a8e7a97042bc36ac22b7ef187 Mon Sep 17 00:00:00 2001 From: Martin Thoma Date: Tue, 5 Jul 2022 13:51:39 +0200 Subject: [PATCH] BUG: Wrong page inserted when PdfMerger.merge is done Caused-by: #207 Why it wasn't detected by the tests: We don't have any tests that check for the correct result of a merge. We just check for exceptions Closes: #1062 --- PyPDF2/_writer.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/PyPDF2/_writer.py b/PyPDF2/_writer.py index 62d3094023..e4599bc746 100644 --- a/PyPDF2/_writer.py +++ b/PyPDF2/_writer.py @@ -913,16 +913,8 @@ def _sweep_indirect_references( if newobj is None: try: newobj = data.pdf.get_object(data) - hash_value = None - if newobj is not None: - hash_value = newobj.hash_value() - # Check if object is already added to pdf. - if hash_value in self._idnum_hash: - return IndirectObject(self._idnum_hash[hash_value], 0, self) self._objects.append(None) # placeholder idnum = len(self._objects) - if hash_value is not None: - self._idnum_hash[hash_value] = idnum newobj_ido = IndirectObject(idnum, 0, self) if data.pdf not in extern_map: extern_map[data.pdf] = {}