Skip to content

BUG: check whether self._info is not None before accessing its indirect_reference property #3349

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

djangovanderheijden
Copy link

I ran into the following error whilst compressing identical objects for a specific input PDF:

AttributeError: 'NoneType' object has no attribute 'indirect_reference'

After taking a closer look, it seems self._info is usually checked for None throughout the code in _writer.py. This one specific line seems to have slipped through the cracks.

@djangovanderheijden djangovanderheijden changed the title Bugfix: check whether self._info is not None before accessing its indirect_reference property BUG: check whether self._info is not None before accessing its indirect_reference property Jul 1, 2025
Copy link

codecov bot commented Jul 1, 2025

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 96.72%. Comparing base (ffd406a) to head (d0d9608).

Files with missing lines Patch % Lines
pypdf/_writer.py 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3349      +/-   ##
==========================================
- Coverage   96.73%   96.72%   -0.02%     
==========================================
  Files          53       53              
  Lines        9064     9065       +1     
  Branches     1676     1677       +1     
==========================================
  Hits         8768     8768              
  Misses        177      177              
- Partials      119      120       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@stefan6419846
Copy link
Collaborator

Thanks for the PR. Please add a corresponding test as well.

@stefan6419846 stefan6419846 added the needs-test A test should be added before this PR is merged. label Jul 1, 2025
@djangovanderheijden
Copy link
Author

Unfortunately I don't have the time to set up and figure out unit testing at this moment. The change is simple enough, so if someone could jump in and help out that'd be great. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-test A test should be added before this PR is merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants