fix(review): warn (not debug) on shadow-classify failure; tidy pymupdf usage
Address PR #855 round 2: - 🔴 _shadow_classify swallowed all exceptions at DEBUG, so a systematic failure (pymupdf bug, memory pressure) is invisible at LOG_LEVEL=INFO and trips SonarQube S2221/S5754. Log at WARNING instead (still best-effort -- indexing is unaffected). - classifier: use `with pymupdf.open(...) as doc` instead of manual try/finally. - tests: release the Pixmap's native memory (del pix) in the image fixtures. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
0347e96679
commit
4bdb0bc6d6
@@ -34,6 +34,7 @@ def _full_page_image_pdf(pages: int = 2) -> bytes:
|
||||
pix = pymupdf.Pixmap(pymupdf.csRGB, pymupdf.IRect(0, 0, 600, 850))
|
||||
pix.clear_with(255)
|
||||
img = pix.tobytes("png")
|
||||
del pix # Pixmap holds native memory; release it before the loop
|
||||
for _ in range(pages):
|
||||
page = doc.new_page(width=595, height=842)
|
||||
page.insert_image(page.rect, stream=img)
|
||||
@@ -103,6 +104,7 @@ def _image_with_mashed_text_pdf(pages: int = 2) -> bytes:
|
||||
pix = pymupdf.Pixmap(pymupdf.csRGB, pymupdf.IRect(0, 0, 600, 850))
|
||||
pix.clear_with(255)
|
||||
img = pix.tobytes("png")
|
||||
del pix # Pixmap holds native memory; release it before the loop
|
||||
mashed = "01322234567mobileoutstandingresilienceacademicachievement " * 3
|
||||
for _ in range(pages):
|
||||
page = doc.new_page(width=595, height=842)
|
||||
|
||||
Reference in New Issue
Block a user