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

bpo-26806: add 30 to the recursion limit in IDLE's shell #13944

Merged
merged 16 commits into from
Jul 6, 2019

Conversation

taleinat
Copy link
Contributor

@taleinat taleinat commented Jun 10, 2019

This is done to compensate for the extra stack frames added by IDLE's shell, which can cause problems when setting the recursion limit to low values.

This wraps sys.setrecursionlimit() and sys.getrecursionlimit(), adding a note about this to their doc-strings.

https://bugs.python.org/issue26806

This is done to compensate for the extra stack frames added by
IDLE itself, which cause problems when setting the recursion limit
to low values.

This wraps sys.setrecursionlimit() and sys.getrecursionlimit()
as invisibly as possible.
@taleinat taleinat force-pushed the bpo-26806/IDLE-recursion-limit branch from c7e1a04 to 7d7b622 Compare June 10, 2019 20:24
@taleinat
Copy link
Contributor Author

@terryjreedy, I couldn't figure out where you'd like this mentioned in which docs. I'm happy to add appropriate wording if you point me in the right direction.

Copy link
Member

@terryjreedy terryjreedy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also see new comment on the issue, which includes some manual tests.

@bedevere-bot
Copy link

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

@terryjreedy
Copy link
Member

Our messages crossed. I worry about the docstring and doc and blurb when we agree on everything else. I considered the PRs you and Cheryl worked on last week a higher priority.

1. define wrapping code at the module level
2. increase recursion limit delta from 25 to 30
3. add a note to the wrapped functions' doc-strings
4. extract the recursion limit delta to a variable
5. rework test and add another one
@taleinat taleinat changed the title bpo-26806: transparently add 25 to the recursion limit in IDLE's shell bpo-26806: add 25 to the recursion limit in IDLE's shell Jun 11, 2019
@taleinat taleinat changed the title bpo-26806: add 25 to the recursion limit in IDLE's shell bpo-26806: add 30 to the recursion limit in IDLE's shell Jun 11, 2019
@taleinat
Copy link
Contributor Author

@terryjreedy, I have made the requested changes; please review again.

@bedevere-bot
Copy link

Thanks for making the requested changes!

@terryjreedy: please review the changes made to this pull request.

@taleinat taleinat force-pushed the bpo-26806/IDLE-recursion-limit branch from 6554218 to 38bab8d Compare June 11, 2019 07:36
@taleinat
Copy link
Contributor Author

taleinat commented Jul 3, 2019

Ping, @terryjreedy. I'd like to get this into 3.8.0.

BTW, should we backport this to 3.7.4?

@@ -713,6 +713,10 @@ or ``print`` or ``write`` to sys.stdout or sys.stderr,
IDLE should be started in a command line window. The secondary subprocess
will then be attached to that window for input and output.

The IDLE code running in the execution process adds frames to the call stack
that would not be there otherwise. IDLE wraps ``sys.getrecursionlimit`` and
``sys.setrecursionlimit`` to reduce their visibility.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"their" is ambiguous here; I suggest "to reduce the visibility of the additional stack frames."

Also, perhaps we should mention that this is not just about visibility? E.g. "to reduce the effect of the additional stack frames".

@taleinat
Copy link
Contributor Author

taleinat commented Jul 5, 2019

@terryjreedy, see my two comments on your recent changes.

@terryjreedy
Copy link
Member

I have made changes (improvements) in response to both comments. I'd like to merge this and move on to other issues.

@taleinat
Copy link
Contributor Author

taleinat commented Jul 6, 2019 via email

@taleinat taleinat merged commit fcf1d00 into python:master Jul 6, 2019
@miss-islington
Copy link
Contributor

Thanks @taleinat for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7, 3.8.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-14621 is a backport of this pull request to the 3.8 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 6, 2019
)

This is done to compensate for the extra stack frames added by
IDLE itself, which cause problems when setting the recursion limit
to low values.

This wraps sys.setrecursionlimit() and sys.getrecursionlimit()
as invisibly as possible.
(cherry picked from commit fcf1d00)

Co-authored-by: Tal Einat <taleinat+github@gmail.com>
@bedevere-bot
Copy link

GH-14622 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 6, 2019
)

This is done to compensate for the extra stack frames added by
IDLE itself, which cause problems when setting the recursion limit
to low values.

This wraps sys.setrecursionlimit() and sys.getrecursionlimit()
as invisibly as possible.
(cherry picked from commit fcf1d00)

Co-authored-by: Tal Einat <taleinat+github@gmail.com>
miss-islington added a commit that referenced this pull request Jul 6, 2019
This is done to compensate for the extra stack frames added by
IDLE itself, which cause problems when setting the recursion limit
to low values.

This wraps sys.setrecursionlimit() and sys.getrecursionlimit()
as invisibly as possible.
(cherry picked from commit fcf1d00)

Co-authored-by: Tal Einat <taleinat+github@gmail.com>
@taleinat taleinat deleted the bpo-26806/IDLE-recursion-limit branch July 6, 2019 12:55
miss-islington added a commit that referenced this pull request Jul 6, 2019
This is done to compensate for the extra stack frames added by
IDLE itself, which cause problems when setting the recursion limit
to low values.

This wraps sys.setrecursionlimit() and sys.getrecursionlimit()
as invisibly as possible.
(cherry picked from commit fcf1d00)

Co-authored-by: Tal Einat <taleinat+github@gmail.com>
@terryjreedy
Copy link
Member

2.7.4?
This will be in 2.7.5. I don't think a cherry-pick request would be worth the cost.

@taleinat
Copy link
Contributor Author

taleinat commented Jul 6, 2019

2.7.4?

No, I did really mean to ask about 3.7.4, but we've already backported to 3.7, so I'll take that as a yes :)

This will be in 2.7.5. I don't think a cherry-pick request would be worth the cost.

I agree.

@ZackerySpytz
Copy link
Contributor

@taleinat @terryjreedy It seems that IDLE fails to start after fcf1d00 when CPython is configured without docstrings (./configure --without-doc-strings). When I run ./python -m idlelib.idle, I see the following:


----------------------------------------
Unhandled server exception!
Thread: SockThread
Client Address:  ('127.0.0.1', 40895)
Request:  <socket.socket fd=3, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 40832), raddr=('127.0.0.1', 40895)>
Traceback (most recent call last):
  File "/home/lubuntu2/cpython/Lib/socketserver.py", line 316, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/home/lubuntu2/cpython/Lib/socketserver.py", line 347, in process_request
    self.finish_request(request, client_address)
  File "/home/lubuntu2/cpython/Lib/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/home/lubuntu2/cpython/Lib/idlelib/rpc.py", line 514, in __init__
    socketserver.BaseRequestHandler.__init__(self, sock, addr, svr)
  File "/home/lubuntu2/cpython/Lib/socketserver.py", line 720, in __init__
    self.handle()
  File "/home/lubuntu2/cpython/Lib/idlelib/run.py", line 511, in handle
    install_recursionlimit_wrappers()
  File "/home/lubuntu2/cpython/Lib/idlelib/run.py", line 332, in install_recursionlimit_wrappers
    setrecursionlimit.__doc__ += "\n\n" + textwrap.fill(textwrap.dedent(f"""\
TypeError: unsupported operand type(s) for +=: 'NoneType' and 'str'

*** Unrecoverable, server exiting!
----------------------------------------
Traceback (most recent call last):
  File "/home/lubuntu2/cpython/Lib/idlelib/rpc.py", line 432, in pollresponse
    message = self.pollmessage(wait)
  File "/home/lubuntu2/cpython/Lib/idlelib/rpc.py", line 384, in pollmessage
    packet = self.pollpacket(wait)
  File "/home/lubuntu2/cpython/Lib/idlelib/rpc.py", line 363, in pollpacket
    raise EOFError
EOFError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/lubuntu2/cpython/Lib/runpy.py", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/lubuntu2/cpython/Lib/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/lubuntu2/cpython/Lib/idlelib/idle.py", line 14, in <module>
    main()
  File "/home/lubuntu2/cpython/Lib/idlelib/pyshell.py", line 1521, in main
    shell = flist.open_shell()
  File "/home/lubuntu2/cpython/Lib/idlelib/pyshell.py", line 330, in open_shell
    if not self.pyshell.begin():
  File "/home/lubuntu2/cpython/Lib/idlelib/pyshell.py", line 1050, in begin
    client = self.interp.start_subprocess()
  File "/home/lubuntu2/cpython/Lib/idlelib/pyshell.py", line 463, in start_subprocess
    self.transfer_path(with_cwd=True)
  File "/home/lubuntu2/cpython/Lib/idlelib/pyshell.py", line 553, in transfer_path
    self.runcommand("""if 1:
  File "/home/lubuntu2/cpython/Lib/idlelib/pyshell.py", line 756, in runcommand
    self.rpcclt.remotequeue("exec", "runcode", (code,), {})
  File "/home/lubuntu2/cpython/Lib/idlelib/rpc.py", line 224, in remotequeue
    return self.asyncreturn(seq)
  File "/home/lubuntu2/cpython/Lib/idlelib/rpc.py", line 248, in asyncreturn
    response = self.getresponse(seq, wait=0.05)
  File "/home/lubuntu2/cpython/Lib/idlelib/rpc.py", line 291, in getresponse
    response = self._getresponse(myseq, wait)
  File "/home/lubuntu2/cpython/Lib/idlelib/rpc.py", line 311, in _getresponse
    response = self.pollresponse(myseq, wait)
  File "/home/lubuntu2/cpython/Lib/idlelib/rpc.py", line 436, in pollresponse
    self.handle_EOF()
  File "/home/lubuntu2/cpython/Lib/idlelib/pyshell.py", line 388, in handle_EOF
    raise EOFError
EOFError

@terryjreedy
Copy link
Member

terryjreedy commented Jul 9, 2019

Having read the IDLE part of #14592 a couple of days before merging, it should have occurred to me that we were adding a bug. The possibility of such an oversight is why I don't try to squeeze in substantial code patched after, or even immediately before a .rc. Fortunately, beginner users of IDLE are unlikely to recompile this way. I just tested the effect of -OO and it also sets doc to None, although only for functions in the code being run, not builtins. I am working on a patch now: #14657.

lisroach pushed a commit to lisroach/cpython that referenced this pull request Sep 10, 2019
)

This is done to compensate for the extra stack frames added by
IDLE itself, which cause problems when setting the recursion limit
to low values.

This wraps sys.setrecursionlimit() and sys.getrecursionlimit()
as invisibly as possible.
DinoV pushed a commit to DinoV/cpython that referenced this pull request Jan 14, 2020
)

This is done to compensate for the extra stack frames added by
IDLE itself, which cause problems when setting the recursion limit
to low values.

This wraps sys.setrecursionlimit() and sys.getrecursionlimit()
as invisibly as possible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants