Skip to content

gh-123369: IDLE now support for REPL-specific commands, like help exit license and quit without the need to call them as functions #123525

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
11 changes: 8 additions & 3 deletions Doc/library/idle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,14 @@ Print Window
Print the current window to the default printer.

Close Window
Close the current window (if an unsaved editor, ask to save; if an unsaved
Shell, ask to quit execution). Calling ``exit()`` or ``close()`` in the Shell
window also closes Shell. If this is the only window, also exit IDLE.
Close the current window. If there is an unsaved editor, you will be prompted
to save your work. If there is an unsaved Shell, you will be asked whether
you want to quit execution.

In the Shell, you can call ``exit()`` or ``quit()`` to close the Shell.
If the :ref:`new interactive interpreter <tut-interac>` is enabled,
IDLE also supports using ``exit`` or ``quit`` without the need to call them
as functions. If this is the only window, closing it will also exit IDLE.

Exit IDLE
Close all windows and quit IDLE (ask to save unsaved edit windows).
Expand Down
10 changes: 9 additions & 1 deletion Lib/idlelib/News3.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
What's New in IDLE 3.14.0
(since 3.13.0)
Released on 2025-10-xx
=========================

gh-123369: IDLE now support for REPL-specific commands, like help, exit,
license and quit, without the need to call them as functions.

What's New in IDLE 3.13.0
(since 3.12.0)
Released on 2024-10-xx
Released on 2024-10-07
=========================


Expand Down
14 changes: 13 additions & 1 deletion Lib/idlelib/pyshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,18 @@ def execfile(self, filename, source=None):
def runsource(self, source):
"Extend base class method: Stuff the source in the line cache first"
filename = self.stuffsource(source)
# Synchronize the new interactive shell in Python 3.13
# help, exit, license and quit without the need to call them as functions
# To disable, set the PYTHON_BASIC_REPL environment variable
if not os.getenv('PYTHON_BASIC_REPL'):
REPL_COMMANDS = {
"quit": "quit()",
"exit": "exit()",
"help": "help()",
"license": "license()"
}
source = REPL_COMMANDS.get(source, source)

# at the moment, InteractiveInterpreter expects str
assert isinstance(source, str)
# InteractiveInterpreter.runsource() calls its runcode() method,
Expand Down Expand Up @@ -1132,7 +1144,7 @@ def short_title(self):
return self.shell_title

COPYRIGHT = \
'Type "help", "copyright", "credits" or "license()" for more information.'
'Type "help", "copyright", "credits" or "license" for more information.'

def begin(self):
self.text.mark_set("iomark", "insert")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
IDLE now support for REPL-specific commands, like :kbd:`help`, :kbd:`exit`,
:kbd:`license` and :kbd:`quit`, without the need to call them as functions.
Loading