-
Notifications
You must be signed in to change notification settings - Fork 1.5k
BUG: properly clean up orphan objects when removing pages #3432
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
Conversation
…ng writer after writes
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3432 +/- ##
==========================================
- Coverage 96.97% 96.96% -0.02%
==========================================
Files 54 54
Lines 9337 9358 +21
Branches 1711 1712 +1
==========================================
+ Hits 9055 9074 +19
- Misses 168 170 +2
Partials 114 114 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This change ensures that failures during the internal rebuild process after removing a page with clean=True do not crash the operation but instead log a warning. Closes py-pdf#3418
Thanks for the PR. Besides the exception handling being untested, I fear that this will have a quite large hit on performance and break with edge cases like incremental mode or similar. The docs are rather clear that I am not sure if we are able to solve this issue without too much overhead or should prefer to document that to remove orphans, the corresponding method should be called at the end. If we still miss some unused objects with this, I prefer to focus on fixing the behavior there instead. |
Hi — thanks again for the review and for pointing out the performance / semantic concerns. Short summary / proposal Rather than forcing a heavy serialize→read→clone rebuild inside
Why this approach
Edge cases / safety
Request for guidance
Thanks again for the feedback — happy to adjust based on your guidance. |
|
Given the feedback from the maintainers, I understand that the approach in this PR (modifying I will close this PR and instead prepare a new one focusing on improving Thanks for the detailed review and guidance! |
This fixes an issue where removing pages after writing left orphan objects in the PDF writer.
The fix forces a rebuild of the internal structure to clean orphaned objects, improving stability and avoiding potential PDF corruption.
Closes #3418