You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: nonlocal truncated declared but never assigned in _emit_rich_line — PDF overflow may go undetected #122
In generation/pdf_renderer.py, the nested function _emit_rich_line declares nonlocal truncated but never assigns to it, making the declaration a no-op and
potentially leaving PDF content overflow undetected.
Steps to reproduce
Open backend/generation/pdf_renderer.py
Find the nested function _emit_rich_line (around line 414)
Note nonlocal truncated at line 419 — no assignment to truncated exists in the function
Run: python -m pyflakes generation/pdf_renderer.py
Output confirms the warning at line 419
Expected behavior
Either:
_emit_rich_line sets truncated = True when rendered content exceeds page bounds, or
The nonlocal truncated declaration is removed if the function intentionally only reads the flag
Without one of these fixes, oversized PDF content processed by this function may not
trigger the truncation guard in the outer scope.
Fixed on dev (commit 9548219), and your report was pointing at something real beyond the lint: emit() pre-measures line height with plain-font widths, but _emit_rich_line renders inline-bold runs, which are wider - so a bold-heavy line could overflow the page without tripping the truncation guard. Two changes: rich lines are now measured as bold (conservative pre-check), and _emit_rich_line flags truncated post-render if the cursor passed the bottom margin, which feeds the existing rebuild-at-smaller-scale loop. The nonlocal is now load-bearing. Ships in the next release.
Activity
vasu-devs commentedon Jul 18, 2026
Fixed on dev (commit 9548219), and your report was pointing at something real beyond the lint: emit() pre-measures line height with plain-font widths, but _emit_rich_line renders inline-bold runs, which are wider - so a bold-heavy line could overflow the page without tripping the truncation guard. Two changes: rich lines are now measured as bold (conservative pre-check), and _emit_rich_line flags truncated post-render if the cursor passed the bottom margin, which feeds the existing rebuild-at-smaller-scale loop. The nonlocal is now load-bearing. Ships in the next release.