Skip to content

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

Open
ammgws wants to merge 5 commits intopython:mainfrom
ammgws:bpo-30082
Open

bpo-30082 Popen: add kwarg to hide process window on Windows#19014
ammgws wants to merge 5 commits intopython:mainfrom
ammgws:bpo-30082

Conversation

@ammgws
Copy link
Copy Markdown

@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
Copy Markdown
Author

ammgws commented Mar 16, 2020

Removed unrelated commit

@csabella csabella requested a review from a team May 28, 2020 00:21
@ammgws
Copy link
Copy Markdown
Author

ammgws commented Oct 13, 2021

Resolved conflicts due to 23c0fb8

Also, what to do about the news entry?

@zooba
Copy link
Copy Markdown
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
Copy Markdown
Author

ammgws commented Oct 16, 2021

Done, cheers!

Comment thread Lib/subprocess.py Outdated
Comment thread Lib/subprocess.py Outdated
@ammgws
Copy link
Copy Markdown
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.

Comment thread Doc/library/subprocess.rst Outdated
Comment thread Doc/library/subprocess.rst Outdated
Comment thread Lib/subprocess.py Outdated
Comment thread Lib/subprocess.py Outdated
@ammgws ammgws marked this pull request as draft October 29, 2021 10:21
@ammgws ammgws marked this pull request as ready for review October 29, 2021 14:59
Comment thread Lib/subprocess.py Outdated
@ammgws
Copy link
Copy Markdown
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 October 30, 2021 07:09
@ammgws ammgws marked this pull request as ready for review October 30, 2021 21:49
Comment thread Lib/test/test_subprocess.py Outdated
Comment thread Lib/subprocess.py Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 7, 2026

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 7, 2026
@python-cla-bot
Copy link
Copy Markdown

python-cla-bot Bot commented Apr 25, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

Copy link
Copy Markdown
Author

@ammgws ammgws Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if something is meant to be done about the date in the filename since it has been years since it was first generated...

@ammgws
Copy link
Copy Markdown
Author

ammgws commented Apr 26, 2026

Hi @eryksun, I have rebased this to resolve merge conflicts. It is from a few years ago but I believe there were no lingering review comments to block this one from proceeding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants