Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure indirect sweep to handle all objects. #1064

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions PyPDF2/_writer.py
Expand Up @@ -922,6 +922,19 @@ def _sweep_indirect_references(
extern_map[data.pdf][data.generation] = {}
extern_map[data.pdf][data.generation][data.idnum] = newobj_ido
newobj = self._sweep_indirect_references(extern_map, newobj)
# Ensure that all objects is handled
MartinThoma marked this conversation as resolved.
Show resolved Hide resolved
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:
newobj_ido = IndirectObject(
self._idnum_hash[hash_value], 0, self
)
self._objects[idnum - 1] = newobj_ido
return newobj_ido
if hash_value is not None:
self._idnum_hash[hash_value] = idnum
self._objects[idnum - 1] = newobj
return newobj_ido
except (ValueError, RecursionError):
Expand Down