Skip to content

gh-74268: Popen: add kwarg to hide process window on Windows - #19014

Draft
ammgws wants to merge 8 commits into
python:mainfrom
ammgws:bpo-30082
Draft

gh-74268: Popen: add kwarg to hide process window on Windows#19014
ammgws wants to merge 8 commits into
python:mainfrom
ammgws:bpo-30082

Conversation

@ammgws

@ammgws ammgws commented Mar 15, 2020

Copy link
Copy Markdown

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

ammgws commented Mar 16, 2020

Copy link
Copy Markdown
Author

Removed unrelated commit

@csabella
csabella requested a review from a team May 28, 2020 00:21
@ammgws

ammgws commented Oct 13, 2021

Copy link
Copy Markdown
Author

Resolved conflicts due to 23c0fb8

Also, what to do about the news entry?

@zooba

zooba commented Oct 16, 2021

Copy link
Copy Markdown
Member

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

ammgws commented Oct 16, 2021

Copy link
Copy Markdown
Author

Done, cheers!

Comment thread Lib/subprocess.py Outdated
Comment thread Lib/subprocess.py Outdated
@ammgws

ammgws commented Oct 28, 2021

Copy link
Copy Markdown
Author

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

ammgws commented Oct 30, 2021

Copy link
Copy Markdown
Author

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
@python-cla-bot

python-cla-bot Bot commented Apr 25, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@ammgws ammgws Apr 25, 2026

Copy link
Copy Markdown
Author

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
ammgws force-pushed the bpo-30082 branch 2 times, most recently from 9d22380 to 3cb1b2d Compare April 25, 2026 09:18
@ammgws

ammgws commented Apr 26, 2026

Copy link
Copy Markdown
Author

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.

@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label May 10, 2026
@github-actions

Copy link
Copy Markdown

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

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Aug 11, 2026
@serhiy-storchaka serhiy-storchaka changed the title bpo-30082 Popen: add kwarg to hide process window on Windows gh-74268: Popen: add kwarg to hide process window on Windows Aug 12, 2026
@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Aug 14, 2026
@read-the-docs-community

read-the-docs-community Bot commented Aug 16, 2026

Copy link
Copy Markdown

@ammgws
ammgws marked this pull request as draft August 16, 2026 00:28
@ammgws
ammgws force-pushed the bpo-30082 branch 4 times, most recently from 55fcf45 to 93f46f5 Compare August 16, 2026 00:54
@ammgws
ammgws force-pushed the bpo-30082 branch 3 times, most recently from 4463669 to 0060f9f Compare August 16, 2026 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants