Skip to content

gh-149231: tomllib: Limit the number of parts in a key#149233

Merged
encukou merged 2 commits intopython:mainfrom
encukou:tomllib-update
May 4, 2026
Merged

gh-149231: tomllib: Limit the number of parts in a key#149233
encukou merged 2 commits intopython:mainfrom
encukou:tomllib-update

Conversation

@encukou
Copy link
Copy Markdown
Member

@encukou encukou commented May 1, 2026

This roughly syncs up with latest tomli. I excluded the (growing number of) mypyc-specific parts.

Copy link
Copy Markdown
Member

@gpshead gpshead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cute re-use of recursionlimit. i could argue for just declaring a max nesting constant instead but realistically the important thing is having a limit at all. this works.

@encukou
Copy link
Copy Markdown
Member Author

encukou commented May 4, 2026

What's invisible here is that tomllib.loads('a = ' + '['*1000 + '0' + ']'*1000) also raises RecursionError, due to an implementation detail -- an actual recursive parser.

@encukou encukou merged commit bc7c102 into python:main May 4, 2026
63 checks passed
@encukou encukou deleted the tomllib-update branch May 4, 2026 11:49
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.

3 participants