Fix NoneType object is not subscriptable from _insert_filtered_annotations #3444
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There are cases where the IndirectObject is not None, but
d[0]
will fail withTypeError: 'NoneType' object is not subscriptable
ingeneric/_base.py
, atreturn self._get_object_with_check()[key]
.I previously reported this issue in #3211, but the fix for that issue didn't fix this one.
Unfortunately i still can't attach the PDF file that triggered this issue, because it contains personal information.
If someone has an idea how to create a PDF to test this with, i'd be happy to try.
I fully understand that a maintainer would not be keen on including fixes for rare bugs without a test.
More details on the error
The script i used to reproduce the error:
In the script directory i have a
broken.pdf
(the offending file i can't share here) and anempty.pdf
.This fails as below:
Setting a breakpoint before the error occurs gives:
(To be fair, in this last example i cheated a bit because the variable name
d
clashes with the pdb command. So i renamed that.)