-
Notifications
You must be signed in to change notification settings - Fork 511
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added test for #2548 and address rebase fail.
Fixed test failure in rebased. We were not converting fz exception into C++ exception in src/extra.i:page_get_textpage(). Also fixed other cases where we leaked fz exception.
- Loading branch information
1 parent
a732f1f
commit e9d58d7
Showing
3 changed files
with
31 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import os | ||
|
||
import fitz | ||
|
||
root = os.path.abspath(f'{__file__}/../..') | ||
|
||
def test_2548(): | ||
"""Text extraction should fail because of PDF structure cycle. | ||
Old MuPDF version did not detect the loop. | ||
""" | ||
doc = fitz.open(f'{root}/tests/resources/test_2548.pdf') | ||
e = False | ||
for page in doc: | ||
try: | ||
_ = page.get_text() | ||
except Exception as ee: | ||
print(f'test_2548: {ee=}') | ||
if hasattr(fitz, 'mupdf'): | ||
# Rebased. | ||
expected = "RuntimeError('code=2: cycle in structure tree')" | ||
else: | ||
# Classic. | ||
expected = "RuntimeError('cycle in structure tree')" | ||
assert repr(ee) == expected, f'Expected {expected=} but got {repr(ee)=}.' | ||
e = True | ||
assert e |