Skip to content

fix(python): enforce recursion depth limits in monty_to_py and py_to_monty#1046

Merged
chaliy merged 3 commits intomainfrom
fix/issue-986-monty-recursion-depth
Apr 4, 2026
Merged

fix(python): enforce recursion depth limits in monty_to_py and py_to_monty#1046
chaliy merged 3 commits intomainfrom
fix/issue-986-monty-recursion-depth

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 3, 2026

Summary

  • Add depth tracking to monty_to_py and py_to_monty conversion functions
  • Enforce MAX_NESTING_DEPTH = 64 consistent with existing JSON conversion limits
  • Return PyValueError when depth exceeded instead of stack overflow
  • Follows exact same pattern as json_to_py_inner / py_to_json_inner

Test plan

  • Deeply nested structures (>64 levels) return graceful error
  • Normal depth structures convert successfully
  • Existing embedded Python builtin tests pass
  • All cargo tests pass

Closes #986

chaliy added 3 commits April 3, 2026 23:25
…monty

Add depth tracking to monty_to_py and py_to_monty conversion functions,
consistent with the existing MAX_NESTING_DEPTH=64 limit used in
json_to_py_inner and py_to_json_inner. Returns PyValueError when depth
is exceeded instead of risking stack overflow.

Closes #986
@chaliy chaliy merged commit bec5aa2 into main Apr 4, 2026
18 checks passed
@chaliy chaliy deleted the fix/issue-986-monty-recursion-depth branch April 4, 2026 01:15
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.

monty_to_py and py_to_monty conversions lack recursion depth limits

1 participant