Skip to content

quit() and exit() don't work in interactive help #112007

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

Closed
catafest opened this issue Nov 12, 2023 · 10 comments
Closed

quit() and exit() don't work in interactive help #112007

catafest opened this issue Nov 12, 2023 · 10 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@catafest
Copy link

catafest commented Nov 12, 2023

Bug report

Bug description:

I tried to use quit and exit to return to the interactive Python shell but these not work. I need to use Ctr +Z.

Python 3.13.0a1 (tags/v3.13.0a1:ad056f0, Oct 13 2023, 09:51:17) [MSC v.1935 64 bit (AMD64)] on win32
# Add a code block here, if required
help> exit()
No Python documentation found for 'exit()'.
Use help() to get the interactive help utility.
Use help(str) for help on the str class.

help> quit()
No Python documentation found for 'quit()'.
Use help() to get the interactive help utility.
Use help(str) for help on the str class.

CPython versions tested on:

3.13

Operating systems tested on:

Windows

Linked PRs

@catafest catafest added the type-bug An unexpected behavior, bug, or error label Nov 12, 2023
@hugovk
Copy link
Member

hugovk commented Nov 12, 2023

Working as expected on macOS, installed using the "macOS 64-bit universal2 installer" from https://www.python.org/downloads/release/python-3130a1/

python3.13
Python 3.13.0a1 (v3.13.0a1:ad056f03ae, Oct 13 2023, 06:35:05) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()python3.13
Python 3.13.0a1 (v3.13.0a1:ad056f03ae, Oct 13 2023, 06:35:05) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()python3.13
Python 3.13.0a1 (v3.13.0a1:ad056f03ae, Oct 13 2023, 06:35:05) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> ^Dpython3.13
Python 3.13.0a1 (v3.13.0a1:ad056f03ae, Oct 13 2023, 06:35:05) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
[1]  + 65866 suspended  python3.13

Also built from latest main:

./python.exe
Python 3.13.0a1+ (heads/main:b2af50cb02, Nov 12 2023, 18:24:40) [Clang 15.0.0 (clang-1500.0.40.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()./python.exe
Python 3.13.0a1+ (heads/main:b2af50cb02, Nov 12 2023, 18:24:40) [Clang 15.0.0 (clang-1500.0.40.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()./python.exe
Python 3.13.0a1+ (heads/main:b2af50cb02, Nov 12 2023, 18:24:40) [Clang 15.0.0 (clang-1500.0.40.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> ^D./python.exe
Python 3.13.0a1+ (heads/main:b2af50cb02, Nov 12 2023, 18:24:40) [Clang 15.0.0 (clang-1500.0.40.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
[2]  + 65953 suspended  ./python.exe

@hugovk
Copy link
Member

hugovk commented Nov 12, 2023

help> exit()
No Python documentation found for 'exit()'.
Use help() to get the interactive help utility.
Use help(str) for help on the str class.

But this bit is interesting, have you run help() first to enter the interactive help?

Do you have the PYTHONSTARTUP env var set and pointing to a startup script?

@DanielFrantes
Copy link

DanielFrantes commented Nov 12, 2023

It works for me. Both shell and IDLE

Windows 11 Home
23H2
22631.2506

@DanielFrantes
Copy link

@catafest Exactly what Windows are you using?

@serhiy-storchaka serhiy-storchaka changed the title quit and exit don't work on interactive shell on Python 3.13.0a1 quit() and exit() don't work on interactive help on Python 3.13.0a1 Nov 12, 2023
@serhiy-storchaka
Copy link
Member

The title was wrong and misleading. The correct title is "quit() and exit() don't work on interactive help".

And this is right. When you enter an interactive help, you get a long introduction message that includes: To quit this help utility and return to the interpreter, just type "quit". Not quit(), simply quit.

@terryjreedy terryjreedy removed the type-bug An unexpected behavior, bug, or error label Nov 13, 2023
@zware zware changed the title quit() and exit() don't work on interactive help on Python 3.13.0a1 quit() and exit() don't work in interactive help Nov 13, 2023
@zware zware added type-bug An unexpected behavior, bug, or error and removed OS-windows labels Nov 13, 2023
@zware
Copy link
Member

zware commented Nov 13, 2023

This isn't version or platform specific. As Serhiy mentioned, there's no bug here from the perspective of an understanding of the code. However, it does strike me as being new user unfriendly, and we may want to improve it. There's an easy fix: just add quit() to the if request.lower() in ('q', 'quit'): break line in pydoc.Helper.interact. Another option would be to check for () in the input and either silently strip it or emit a "you probably didn't mean this here" message.

@terryjreedy terryjreedy removed the type-bug An unexpected behavior, bug, or error label Nov 13, 2023
terryjreedy added a commit to terryjreedy/cpython that referenced this issue Nov 13, 2023
Most important: move how-to-quit sentence to the end.
@terryjreedy
Copy link
Member

I think that this sentence, 'To quit this help utility and return to the interpreter, just type "quit".' in pydoc.Helper.intro should be moved to the end after a blank line. It is now in the middle of things to do other than quitting. I suspect that it was once the last sentence before more was added. I will submit a PR with this and a couple of other re-groupings.

@terryjreedy terryjreedy added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Nov 13, 2023
@terryjreedy
Copy link
Member

To me, changing this string in the pydoc module is equivalent to a doc change and should be backported. test_pydoc still passes as is, and I don't think anyone else should depend on the exact content. Any disagreement?

@terryjreedy
Copy link
Member

I added 'q' as an alternative. I had not idea that it worked until I read the code quoted above by 'zware'.

terryjreedy added a commit that referenced this issue Nov 13, 2023
Most important: move how-to-quit sentence to the end and mention 'q'.
Re-group the other sentences and improve some wording.
---------
Co-authored-by: Hugo van Kemenade <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Nov 13, 2023
)

Most important: move how-to-quit sentence to the end and mention 'q'.
Re-group the other sentences and improve some wording.
---------
Co-authored-by: Hugo van Kemenade <[email protected]>
(cherry picked from commit b28bb13)

Co-authored-by: Terry Jan Reedy <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Nov 13, 2023
)

Most important: move how-to-quit sentence to the end and mention 'q'.
Re-group the other sentences and improve some wording.
---------
Co-authored-by: Hugo van Kemenade <[email protected]>
(cherry picked from commit b28bb13)

Co-authored-by: Terry Jan Reedy <[email protected]>
terryjreedy added a commit that referenced this issue Nov 13, 2023
…112048)

gh-112007: Re-organize help utility intro message (GH-112017)

Most important: move how-to-quit sentence to the end and mention 'q'.
Re-group the other sentences and improve some wording.
---------

(cherry picked from commit b28bb13)

Co-authored-by: Terry Jan Reedy <[email protected]>
terryjreedy added a commit that referenced this issue Nov 13, 2023
…112047)

gh-112007: Re-organize help utility intro message (GH-112017)

Most important: move how-to-quit sentence to the end and mention 'q'.
Re-group the other sentences and improve some wording.
---------

(cherry picked from commit b28bb13)

Co-authored-by: Terry Jan Reedy <[email protected]>
@terryjreedy
Copy link
Member

I think that this revision should be sufficient for now. The previously not mentioned 'q', now easy to see, is the easiest way to exit.

aisk pushed a commit to aisk/cpython that referenced this issue Feb 11, 2024
Most important: move how-to-quit sentence to the end and mention 'q'.
Re-group the other sentences and improve some wording.
---------
Co-authored-by: Hugo van Kemenade <[email protected]>
Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
Most important: move how-to-quit sentence to the end and mention 'q'.
Re-group the other sentences and improve some wording.
---------
Co-authored-by: Hugo van Kemenade <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

6 participants