Skip to content

Commit 56f43fc

Browse files
src/__init__.py tests/: Partial fix for #4928 - exception in Document.scrub().
We fix the original problem in _load_annot(), but there is a later exception.
1 parent 7d03601 commit 56f43fc

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10187,7 +10187,7 @@ def _load_annot(self, name, xref):
1018710187
annot = JM_get_annot_by_name(page, name)
1018810188
else:
1018910189
annot = JM_get_annot_by_xref(page, xref)
10190-
if annot.m_internal:
10190+
if annot:
1019110191
return Annot(annot)
1019210192

1019310193
def _makePixmap(self, doc, ctm, cs, alpha=0, annots=1, clip=None):

tests/resources/test_4928.pdf

1.79 KB
Binary file not shown.

tests/test_general.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,3 +2212,12 @@ def test_4907():
22122212
print(f'{i=}')
22132213
display_list = page.get_displaylist(annots=False)
22142214
text_page = display_list.get_textpage()
2215+
2216+
def test_4928():
2217+
path = os.path.normpath(f'{__file__}/../../tests/resources/test_4928.pdf')
2218+
with pymupdf.open(path) as document:
2219+
try:
2220+
document.scrub()
2221+
except Exception as e:
2222+
print(f'Ignoring expected exception: {e}')
2223+

0 commit comments

Comments
 (0)