Skip to content

Commit 0d799f7

Browse files
committed
Python: Increase recursion limit for deeply nested LST nodes (#6792)
Deeply nested Py.Binary nodes (e.g., 256 implicitly concatenated strings in asn1crypto/_teletex_codec.py) overflow Python's default recursion limit (1000) during RPC serialization. Double it to 2000.
1 parent 75019a9 commit 0d799f7

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

  • rewrite-python/rewrite/src/rewrite/rpc

rewrite-python/rewrite/src/rewrite/rpc/server.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,15 @@
3030
import tempfile
3131
import traceback
3232
import threading
33+
3334
from pathlib import Path
3435
from typing import Dict, Any, Optional, List, Callable
3536
from uuid import uuid4
3637

38+
# Deeply nested LST nodes (e.g., 256 implicitly concatenated strings) can
39+
# overflow the default recursion limit (1000) during RPC serialization.
40+
sys.setrecursionlimit(sys.getrecursionlimit() * 2)
41+
3742
# Configure logging - log to file by default to avoid filling stderr buffer
3843
# (which can cause deadlock if parent process doesn't read stderr)
3944
_default_log_file = os.path.join(tempfile.gettempdir(), 'python-rpc.log')

0 commit comments

Comments
 (0)