Repository navigation
[Doc] Fix os.spawn* functions - #121094
Conversation
…#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.
|
The reason why
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). |
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 |
|
Oh actually I got misleaded! Actually, those ones have indeed nothing to do with
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
e54d2ca to
36d122e
Compare
The problem is not in the function definition. There all A similar problem occurs with |
|
This PR is stale because it has been open for 30 days with no activity. |
encukou
left a comment
There was a problem hiding this comment.
The semantics of the p variants are explained appropriately in the text.
The argument name is file, which means this works:
>>> os.spawnv(mode=os.P_WAIT, file='/usr/bin/echo', args=['echo', 'hi'])
hi
0but this doesn't:
>>> os.spawnv(mode=os.P_WAIT, path='/usr/bin/echo', args=['echo', 'hi'])
Traceback (most recent call last):
File "<python-input-12>", line 1, in <module>
os.spawnv(mode=os.P_WAIT, path='/usr/bin/echo', args=['echo', 'hi'])
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: spawnv() got an unexpected keyword argument 'path'Arguably, no one would rely on that detail. Still, it's better if the docs are correct :)
Documentation build overview
|
|
Thanks @adorilson for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15. |
|
GH-161412 is a backport of this pull request to the 3.15 branch. |
|
GH-161413 is a backport of this pull request to the 3.14 branch. |
…-161412) Replace argument names *path* for *file*, the real names from them. It's possible to pass these as keyword arguments to the `*v*` functions; the following doesn't work: os.spawnv(mode=os.P_WAIT, path='/usr/bin/echo', args=['echo', 'hi']) (cherry picked from commit 288cc2b) Co-authored-by: Adorilson Bezerra <adorilson@gmail.com>
…-161413) Replace argument names *path* for *file*, the real names from them. It's possible to pass these as keyword arguments to the `*v*` functions; the following doesn't work: os.spawnv(mode=os.P_WAIT, path='/usr/bin/echo', args=['echo', 'hi']) (cherry picked from commit 288cc2b) Co-authored-by: Adorilson Bezerra <adorilson@gmail.com>
This PR makes the documentation more suitable with the functions definitions in the source code and removes a inconsistency when the reader reads
filein the functions assignature, but the first line below citespath.📚 Documentation preview 📚: https://cpython-previews--121094.org.readthedocs.build/