-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
gh-125562: Update to documentation for exec* functions #125565
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?
Conversation
…() documentation sections
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.
Putting the bracketed deprecation paragraphs at the top of each description is not great. Maybe move them down, if needed at all.
Doc/library/os.rst
Outdated
The various :func:`exec\* <execl>` functions take a list of arguments for the new | ||
program loaded into the process. In each case, the first of these arguments must | ||
be the name of the program itself, and not an argument that a user may | ||
have typed on a command line. |
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.
Since you already edited the second sentence, I’ll point out that often the first word on a command line is indeed the program name (e.g. shell command “echo bar”) so saying “not an argument . . . typed on a command line” is confusing if not wrong.
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'm open to any suggestions as to better wording? That phrasing came from the original documentation, I agree it's not great but I found it difficult to come up with something better that I was confident was correct.
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.
Here is my attempt:
The exec functions take a list of arguments for the new program. The first of these is by convention the command name from the command line, rather than an argument to the command, and becomes argv[0] passed to the main function of a C program. For example, os.execv('/bin/echo', ['echo', 'foo', 'bar']) would only print foo bar; the echo argument would seem to be ignored.
Doc/library/os.rst
Outdated
be the name of the program itself, and not an argument that a user may | ||
have typed on a command line. | ||
|
||
For the C programmer, this is the ``argv[0]`` |
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’m not sure breaking the paragraph works. “This” refers to the name of the program (topic of the last sentence of the last paragraph), not the overall Program Arguments heading.
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 decided to retain the paragraph break and instead reworded the first sentence in the paragraph. I'm not entirely sure what the documentation is getting at with the second sentence in the paragraph. I'm open to further suggestions for improving this paragraph - I feel it could be improved but I'm not sure how.
Co-authored-by: Martin Panter <vadmium@users.noreply.github.com>
…n instead of execl
Co-authored-by: Martin Panter <vadmium@users.noreply.github.com>
Doc/library/os.rst
Outdated
The various :func:`exec\* <execl>` functions take a list of arguments for the new | ||
program loaded into the process. In each case, the first of these arguments must | ||
be the name of the program itself, and not an argument that a user may | ||
have typed on a command line. |
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.
Here is my attempt:
The exec functions take a list of arguments for the new program. The first of these is by convention the command name from the command line, rather than an argument to the command, and becomes argv[0] passed to the main function of a C program. For example, os.execv('/bin/echo', ['echo', 'foo', 'bar']) would only print foo bar; the echo argument would seem to be ignored.
Incorporated vadmium's suggestion to reference the environment variables section Co-authored-by: Martin Panter <vadmium@users.noreply.github.com>
gh-125562: Update to documentation for exec* functions
This PR includes the following changes:
exec*
functions from the start of the Process Management section to the documentation of theexec*
functions.exec*
documentation.exec*
functions documentation to the "Location of the executable", which is where it is logically relevant.system()
,execl
andspawnl
functions.subprocess
module.📚 Documentation preview 📚: https://cpython-previews--125565.org.readthedocs.build/