Skip to content

Commit c8c61f1

Browse files
committed
Only increase recursion limit for PyPy
1 parent 307a395 commit c8c61f1

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

ChangeLog

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Release date: TBA
2020

2121
Closes PyCQA/pylint#8074
2222

23-
* Set a higher recursion limit at ``2**12``, instead of ``1000``
23+
* Set a higher recursion limit at ``2**12`` for PyPy, instead of ``1000``
2424
to prevent accidental ``RecursionErrors``.
2525

2626

astroid/__init__.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,15 @@
4949
from astroid.bases import BaseInstance, BoundMethod, Instance, UnboundMethod
5050
from astroid.brain.helpers import register_module_extender
5151
from astroid.builder import extract_node, parse
52-
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+
)
5361
from astroid.exceptions import (
5462
AstroidBuildingError,
5563
AstroidBuildingException,
@@ -192,8 +200,9 @@
192200
):
193201
tokenize._compile = functools.lru_cache()(tokenize._compile) # type: ignore[attr-defined]
194202

195-
# Set a higher recursion limit. 10**3 is a bit low. Especially for PyPy.
196-
sys.setrecursionlimit(2**12)
203+
if IS_PYPY:
204+
# Set a higher recursion limit for PyPy. 1000 is a bit low.
205+
sys.setrecursionlimit(2**12)
197206

198207
# load brain plugins
199208
for module in BRAIN_MODULES_DIRECTORY.iterdir():

0 commit comments

Comments
 (0)