-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
gh-142474: Clarify -i interaction with PYTHONSTARTUP #142502
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
base: main
Are you sure you want to change the base?
gh-142474: Clarify -i interaction with PYTHONSTARTUP #142502
Conversation
| Enter interactive mode after execution, or force interactive mode even when | ||
| :data:`sys.stdin` does not appear to be a terminal. |
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.
I would probably rewrite it as it is worded in python --help.
forces a prompt even if stdin does not appear to be a terminal
Saying "interactive" is not quite correct, "prompt" better describes it.
|
@vstinner, would you mind giving this a look? |
| :envvar:`PYTHONSTARTUP` file is not read. | ||
| In these "execute then interact" cases, Python runs the script or command | ||
| first and does not read the :envvar:`PYTHONSTARTUP` file before entering | ||
| interactive mode. |
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.
I don't understand this paragraph (it looks wrong). For example, PYTHONSTARTUP=script.py ./python -i -c pass does execute script.py.
Summary
Clarify the documentation for the
-icommand-line option so that it accurately reflects how it interacts withPYTHONSTARTUP.The updated text distinguishes the two distinct behaviors of
-i:When
-iis used with a script or with-c, Python executes the script or command and then enters interactive mode. In these “execute then interact” cases,PYTHONSTARTUPis not read.When
-iis used solely to force interactive mode even ifstdinis not a terminal (for example with redirected standard input), the interpreter enters interactive mode directly andPYTHONSTARTUPis read as usual. The previous documentation implied it was never read when using-i.Issue number
Closes gh-142474.
Type of change
Testing
make html) to confirm RST formatting.-iandPYTHONSTARTUP.Notes
.github/CONTRIBUTING.rst, no NEWS entry is required for this small documentation clarification.📚 Documentation preview 📚: https://cpython-previews--142502.org.readthedocs.build/