Skip to content

The os.execv* family has problems with strings on Windows #143328

@chris-eibl

Description

@chris-eibl

Bug report

Bug description:

import os
import sys

args = [sys.executable, '-c', 'print("hello from execve")']
os.execve(args[0], args, {})

results in

    print(hello from execve)
                ^^^^
SyntaxError: invalid syntax

Using

args = [sys.executable, '-c', "print('hello from execve')"]

results in

    print('hello
          ^
SyntaxError: unterminated string literal (detected at line 1)

Both work like expected in WSL or native Ubuntu.

The only thing that somewhat works is omitting the spaces "print('hellofromexecve')" in the second case.

3.15 back to and including 3.10 are affected.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions