Repository navigation
Stop definition list nesting short of the recursion limit - #1701
Open
rahul05ranjan wants to merge 1 commit into
Open
rahul05ranjan wants to merge 1 commit into
rahul05ranjan wants to merge 1 commit into
Conversation
DefListProcessor.run calls parseBlocks on the definition content, which can contain further definitions, so a document of flat term/definition pairs without blank lines nests once per pair and raises an uncaught RecursionError from only ~5 KB of input. DefListProcessor.test now declines to run near the recursion limit, the same guard BlockquoteProcessor already uses; the remaining markers are kept as text. Fixes Python-Markdown#1700 Co-authored-by: rahul05ranjan <11793455+rahul05ranjan@users.noreply.github.com>
waylan
requested changes
Nov 9, 2026
waylan
left a comment
Member
There was a problem hiding this comment.
This looks good. Thank you. If you make the minor fix noted below and add a changelog entry, I'll merge this.
| self.assertIn('term', result) | ||
|
|
||
| def test_deeply_nested_definitions_do_not_raise(self): | ||
| # Around 5 KB of input, which raised RecursionError before the limit was applied. |
Member
There was a problem hiding this comment.
RecursionError should be in a code span to avoid tripping up the spellchecker.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
def_listextension raises an uncaughtRecursionErroron a flat document of term/definition pairs without blank lines (#1700):DefListProcessor.runcallsparseBlockson the definition content, and with no blank lines each remainingterm\n: definitionpair nests one level deeper — so only ~5 KB of input (linear in recursion depth) reaches the interpreter's limit.Change
DefListProcessor.testnow declines to run near the recursion limit — the same guardBlockquoteProcessor.testalready applies — so the remaining markers are kept as text, exactly as for blockquotes and (per #1685) lists.Verification
TestDefListNestingLimit(tests/test_syntax/extensions/test_def_list.py), following the conventions of Stop list nesting short of the recursion limit #1685'sTestListNestingLimit: therecursionlimit(120)nesting-stops test and the 600-pair no-crash test fail on master (RecursionError), the shallow-nesting render test pins existing behavior; all pass with this changetests/test_syntax/extensions/test_md_in_html.pyexcluded locally (itsTestSuitehelper class doesn't collect under the host's pytest 9, an environment quirk unrelated to this change)PYTHONPATH(pygments2.21.0;markdownbuilt locally with the repo's ownsetup.pyfor entry-point loading); nothing installedFixes #1700