The Wayback Machine - https://web.archive.org/web/20221223141251/https://github.com/python/cpython/pull/19014
Skip to content
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

bpo-30082 Popen: add kwarg to hide process window on Windows #19014

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ammgws
Copy link

@ammgws ammgws commented Mar 15, 2020

https://bugs.python.org/issue30082

Before: On Windows, pythonw opens a console window

After: On Windows, pythonw no longer opens a console window if force_hide is set

Test script:

import subprocess

subprocess.run(
    [
        "C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe",
        "-command",
        "Start-Sleep -Seconds 3; notepad.exe",
    ],
    check=True,
    # added in this PR:
    force_hide=True,
)

@ammgws
Copy link
Author

ammgws commented Mar 16, 2020

Removed unrelated commit

@csabella csabella requested a review from a team May 28, 2020
@ammgws
Copy link
Author

ammgws commented Oct 13, 2021

Resolved conflicts due to 23c0fb8

Also, what to do about the news entry?

@zooba
Copy link
Member

zooba commented Oct 16, 2021

Add a NEWS entry to the Windows section that reads:

Adds new ``force_hide`` argument to :mod:`subprocess` functions.
This passes ``SW_HIDE`` to the new process, which most applications
will use to not display any window even if they normally would.

@ammgws
Copy link
Author

ammgws commented Oct 16, 2021

Done, cheers!

Lib/subprocess.py Outdated Show resolved Hide resolved
Lib/subprocess.py Outdated Show resolved Hide resolved
@ammgws
Copy link
Author

ammgws commented Oct 28, 2021

I had a go at updating the docs as well, but I suspect it could be better worded so any layman could understand the differences between the two options.

Doc/library/subprocess.rst Outdated Show resolved Hide resolved
Doc/library/subprocess.rst Outdated Show resolved Hide resolved
Lib/subprocess.py Outdated Show resolved Hide resolved
Lib/subprocess.py Outdated Show resolved Hide resolved
@ammgws ammgws marked this pull request as draft Oct 29, 2021
@ammgws ammgws marked this pull request as ready for review Oct 29, 2021
Lib/subprocess.py Show resolved Hide resolved
@ammgws
Copy link
Author

ammgws commented Oct 30, 2021

def write_windows_console(self, *args):

This could be replaced with force_hide

@ammgws ammgws marked this pull request as draft Oct 30, 2021
@ammgws ammgws marked this pull request as ready for review Oct 30, 2021
Lib/test/test_subprocess.py Outdated Show resolved Hide resolved
Lib/subprocess.py Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants