Skip to content

Commit 68bf7d5

Browse files
authored
Set higher recusion limit (2**12) for PyPy (#1984)
1 parent a0d219c commit 68bf7d5

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ Release date: TBA
2020

2121
Closes PyCQA/pylint#8074
2222

23+
* Set a higher recursion limit at ``2**12`` for PyPy, instead of ``1000``
24+
to prevent accidental ``RecursionErrors``.
25+
2326

2427
What's New in astroid 2.13.3?
2528
=============================

astroid/__init__.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"""
3232

3333
import functools
34+
import sys
3435
import tokenize
3536
from importlib import import_module
3637

@@ -48,7 +49,15 @@
4849
from astroid.bases import BaseInstance, BoundMethod, Instance, UnboundMethod
4950
from astroid.brain.helpers import register_module_extender
5051
from astroid.builder import extract_node, parse
51-
from astroid.const import BRAIN_MODULES_DIRECTORY, PY310_PLUS, Context, Del, Load, Store
52+
from astroid.const import (
53+
BRAIN_MODULES_DIRECTORY,
54+
IS_PYPY,
55+
PY310_PLUS,
56+
Context,
57+
Del,
58+
Load,
59+
Store,
60+
)
5261
from astroid.exceptions import (
5362
AstroidBuildingError,
5463
AstroidBuildingException,
@@ -191,6 +200,10 @@
191200
):
192201
tokenize._compile = functools.lru_cache()(tokenize._compile) # type: ignore[attr-defined]
193202

203+
if IS_PYPY:
204+
# Set a higher recursion limit for PyPy. 1000 is a bit low.
205+
sys.setrecursionlimit(2**12)
206+
194207
# load brain plugins
195208
for module in BRAIN_MODULES_DIRECTORY.iterdir():
196209
if module.suffix == ".py":

0 commit comments

Comments
 (0)