Skip to content

🐛 FIX: wrong warning locations after {eval-rst} includes - #1250

Open
sniwas wants to merge 1 commit into
executablebooks:masterfrom
sniwas:eval-rst-include-lines
Open

sniwas wants to merge 1 commit into
executablebooks:masterfrom
sniwas:eval-rst-include-lines

Conversation

@sniwas

@sniwas sniwas commented Nov 27, 2026

Copy link
Copy Markdown

Fixes #1249

render_restructuredtext parses each {eval-rst} block with a new state machine but the page's reporter. docutils binds reporter.get_source_and_line only if the reporter does not have one yet, so a block (or a later role) could look up its line in the wrong place: an earlier block's input, which .. include:: had lengthened, or the identity lambda set by MockState.

The existing lookup is now removed while the block is parsed, so the block's own RSTState binds it, and restored afterwards (the same save/restore used for {include}). This is the change suggested in the issue.

  • The new test in test_error_reporting.py covers both cases from the issue; it fails without the fix and passes with it.
  • The reproduction script from the issue now prints the expected output.
  • Full test suite locally (Windows, Python 3.12): 3 failures (test_cmdline[40-linkify], test_extended_syntaxes, test_extended_syntaxes_text) that also occur without this change; the rest pass or are skipped.
  • ruff check and ruff format --check pass.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

{eval-rst} with .. include:: gives later warnings on the page the wrong file and line

1 participant