X Tutup
The Wayback Machine - https://web.archive.org/web/20251004111220/https://github.com/python/cpython/pull/121094
Skip to content

Conversation

adorilson
Copy link
Contributor

@adorilson adorilson commented Jun 27, 2024

This PR makes the documentation more suitable with the functions definitions in the source code and removes a inconsistency when the reader reads file in the functions assignature, but the first line below cites path.


📚 Documentation preview 📚: https://cpython-previews--121094.org.readthedocs.build/

vstinner and others added 3 commits June 25, 2024 22:23
…#106335)

Remove private _PyThreadState and _PyInterpreterState C API
functions: move them to the internal C API (pycore_pystate.h and
pycore_interp.h). Don't export most of these functions anymore, but
still export functions used by tests.

Remove _PyThreadState_Prealloc() and _PyThreadState_Init() from the C
API, but keep it in the stable API.
This reverts commit ebfa093.
@bedevere-app bedevere-app bot added docs Documentation in the Doc dir skip news awaiting review labels Jun 27, 2024
@picnixz
Copy link
Member

picnixz commented Jun 27, 2024

The reason why spawn uses path is probably because it handles its argument similarly to how posix_spawn does in C.

The only difference between posix_spawn() and posix_spawnp() is the manner in which they specify the
file to be executed by the child process. With posix_spawn(), the executable file is specified as a
pathname (which can be absolute or relative). With posix_spawnp(), the executable file is specified
as a simple filename; the system searches for this file in the list of directories specified by PATH
(in the same way as for execvp(3))

In particular, the semantics of path and file are distinct. Concerning the code source of Python itself, I think that's the one that should be changed (and not the docs themselves in this case).

However, we could be a bit more precise in the docs (but for that, I'd check the C code first).

@adorilson
Copy link
Contributor Author

Concerning the code source of Python itself, I think that's the one that should be changed (and not the docs themselves in this case).

Here the problem is the consequences. See this @gpshead's comment: https://discuss.python.org/t/is-time-to-remove-os-module-spawn-functions/55829/7

@picnixz
Copy link
Member

picnixz commented Jun 27, 2024

Oh actually I got misleaded! Actually, those ones have indeed nothing to do with posix_* but they actually seem to use the same conventions:

The variants which include a second “p” near the end (spawnlp(), spawnlpe(), spawnvp(), and spawnvpe()) will use the PATH environment variable to locate the program file. When the environment is being replaced (using one of the spawn*e variants, discussed in the next paragraph), the new environment is used as the source of the PATH variable. The other variants, spawnl(), spawnle(), spawnv(), and spawnve(), will not use the PATH variable to locate the executable; path must contain an appropriate absolute or relative path.

While my previous comment was incorrect, the rationale of why those names were used is probably what I thought about.

Replace argument names *path*  for *file*, the real names from them
@adorilson adorilson force-pushed the fix_spawn_functions_doc branch from e54d2ca to 36d122e Compare June 27, 2024 16:08
@adorilson
Copy link
Contributor Author

While my previous comment was incorrect, the rationale of why those names were used is probably what I thought about.

The problem is not in the function definition. There all spawn function uses file. The problem is only in the documentation at docs.python.org. The documentation strings are correct.

A similar problem occurs with os.startfile, where there is another PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review docs Documentation in the Doc dir skip news
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

3 participants
X Tutup