Skip to content

Catch RecursionError in the regex format checker - #1540

Open
UlikGames wants to merge 1 commit into
python-jsonschema:mainfrom
UlikGames:fix/1538-regex-recursion-error
Open

Catch RecursionError in the regex format checker#1540
UlikGames wants to merge 1 commit into
python-jsonschema:mainfrom
UlikGames:fix/1538-regex-recursion-error

Conversation

@UlikGames

Copy link
Copy Markdown

Fixes #1538

re.compile raises RecursionError rather than re.error when a pattern nests deeply enough to hit the C stack limit, so the checker's raises=re.error didn't cover it and the exception escaped the validator instead of being reported as an invalid instance.

Added RecursionError to the tuple, plus a test with "(" * 500. Same shape as the OverflowError case in #1526, just a different exception type.

Full test suite passes locally.

re.compile raises RecursionError, not re.error, when a pattern nests
deeply enough to blow the C stack, so the exception escaped the format
checker instead of being turned into a FormatError.
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 python-jsonschema | 🛠️ Build #33870167 | 📁 Comparing d435a94 against latest (826e5b2)

  🔍 Preview build  

1 file changed
± _modules/jsonschema/_format/index.html

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.

regex format checker crashes with RecursionError on deeply nested patterns

1 participant