← 输入框|github.com|刷新
Skip to content

Cannot os.spawnl with no arguments  #126931

Description

@CitrusWire

Bug report

Bug description:

Python 3.8 and 3.11.9

Probably related to: #52284
Seems to be the same as: #63130

A number of bugs:

    • Doesn't work with no arguements.
>>> os.spawnl(os.P_NOWAIT, "c:\path_to_some_program\app.exe")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<frozen os>", line 930, in spawnl
ValueError: spawnv() arg 2 cannot be empty
  1. If I try and make the arguement empty it also fails. This means that I am forced to send an arguement that may trigger an unknown behaviour in the spawned application.:
>>> os.spawnl(os.P_NOWAIT, "c:\path_to_some_program\app.exe", '')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<frozen os>", line 930, in spawnl
ValueError: spawnv() arg 2 first element cannot be empty
  1. If any aspect of this is intended, then the documentation needs to be updated to explicitly say this. Currently it implies any arguments are optional. (Honestly, the docs for this are bad generally.)

CPython versions tested on:

3.11

Operating systems tested on:

Windows

Linked PRs

Activity

  1. added
    type-bug
    on Nov 17, 2024
  2. ronaldoussoren commented on Nov 17, 2024

    @ronaldoussoren
    Contributor

    Note that the arguments passed are all arguments seen by the program, including argv[0].

    The example in the docs at https://docs.python.org/3/library/os.html#os.spawnvpe shows this:

    import os
    os.spawnlp(os.P_WAIT, 'cp', 'cp', 'index.html', '/dev/null')

    Note that 'cp' is listed twice, first as the name of the executable to start and then as the value seen in argv[0] of the spawned program.

  3. picnixz commented on Nov 17, 2024

    @picnixz
    Member

    I think it's a doc issue but I can't be entirely sure about it. spanwl has a signature (mode, path, ...) so it's correct to perhaps assume that 2 arguments is enough.

  4. added
    docs
    on Nov 18, 2024
  5. CitrusWire commented on Nov 19, 2024

    @CitrusWire
    Author

    Note that the arguments passed are all arguments seen by the program, including argv[0].

    The example in the docs at https://docs.python.org/3/library/os.html#os.spawnvpe shows this

    Several things:

    • A user should not need to look at a different method's documentation to understand how to use this specific method.
    • What if I don't want any arguments passed to the spawned program? To me that seems like it could become a security issue because you're sending spurious arguements to probably a third-party program, and you don't know how that program will react to them.

    spanwl has a signature (mode, path, ...) so it's correct to perhaps assume that 2 arguments is enough.

    This is certainly one of the things that confused me.

  6. moved this from Todo to In Progress in OS issues 💻on Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docstype-bug

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions