-
Notifications
You must be signed in to change notification settings - Fork 180
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
Manage recursion limit preventing RuntimeError #68
base: main
Are you sure you want to change the base?
Conversation
I've gone for the simple workaround for https://bugs.launchpad.net/pyflakes/+bug/1507827 , as this is the only Exception I can find, and the alternative (flattening) is a complex patch not suitable for a patch or even minor release. I'd really like this solved, as it means I can run I have one more minor bug in my flatten patch, but should have it up in a few hours. It is easy enough to verify for unary/boolean/binary ops only, but the bug would still exist elsewhere. Solving it for boolean/binary op is not easy, as boolean/binary ops can contain lambda's, and pyflakes has deferred processing of lambdas. I've fixed that problem - my issue is now just generators on py2.7 only. What I do know is the fix is going to need a lot of vetting & testing before it is released. |
#70 is the companion patch, which reduces the recursion so it doesnt hit the limit easily. It still can hit the limit for extremely crazy code, but it is quite improbable. I'm going to slightly refactor this patch (68) so it is less of a performance hit, so it can be merged into the 1.2. or 1.x series promptly. |
b7ff168
to
a1eba06
Compare
a1eba06
to
bf41b09
Compare
pyflakes/test/test_other.py
Outdated
|
||
def test_recursion_limit(self): | ||
# Using self._recursionlimit * 10 tends to cause CPython to core dump. | ||
r = range(self._recursionlimit * 9) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of segmentation fault now after a rebase, on self._recursionlimit * 9
I'll try reducing it.
775c200
to
e2488ff
Compare
pyflakes has traditionally recursed with a handler for every level of the ast. The ast depth can become very large, especially for an expression containing many binary operators. Python has a maximum recursion limit, defaulting to a low number like 1000, which resulted in a RuntimeError for the ast of: x = 1 + 2 + 3 + ... + 1001 To workaround this problem, pyflakes now increases the recursion limit at runtime when it knows it will be exceeded. Fixes lp:1507827
The test is failing on older versions of PyPy only. |
pyflakes has traditionally recursed with a handler for every
level of the ast. The ast depth can become very large, especially
for an expression containing many binary operators.
Python has a maximum recursion limit, defaulting to a low number
like 1000, which resulted in a RuntimeError for the ast of:
To workaround this problem, pyflakes now increases the recursion
limit at runtime when it knows it will be exceeded.
Fixes lp:1507827