Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set higher recusion limit (2**12) for PyPy #1984

Merged
merged 2 commits into from
Jan 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ Release date: TBA

Closes PyCQA/pylint#8074

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


What's New in astroid 2.13.3?
=============================
Expand Down
15 changes: 14 additions & 1 deletion astroid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"""

import functools
import sys
import tokenize
from importlib import import_module

Expand All @@ -48,7 +49,15 @@
from astroid.bases import BaseInstance, BoundMethod, Instance, UnboundMethod
from astroid.brain.helpers import register_module_extender
from astroid.builder import extract_node, parse
from astroid.const import BRAIN_MODULES_DIRECTORY, PY310_PLUS, Context, Del, Load, Store
from astroid.const import (
BRAIN_MODULES_DIRECTORY,
IS_PYPY,
PY310_PLUS,
Context,
Del,
Load,
Store,
)
from astroid.exceptions import (
AstroidBuildingError,
AstroidBuildingException,
Expand Down Expand Up @@ -191,6 +200,10 @@
):
tokenize._compile = functools.lru_cache()(tokenize._compile) # type: ignore[attr-defined]

if IS_PYPY:
# Set a higher recursion limit for PyPy. 1000 is a bit low.
sys.setrecursionlimit(2**12)

# load brain plugins
for module in BRAIN_MODULES_DIRECTORY.iterdir():
if module.suffix == ".py":
Expand Down