This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: subprocess: reusing STARTUPINFO breaks under 3.7 (Windows)
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.8, Python 3.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: eryksun, vstinner, xflr6
Priority: normal Keywords: patch

Created on 2018-07-04 14:55 by xflr6, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 8090 merged vstinner, 2018-07-04 15:16
PR 8120 closed miss-islington, 2018-07-05 20:54
PR 8121 merged vstinner, 2018-07-05 20:59
Messages (5)
msg321047 - (view) Author: Sebastian Bank (xflr6) Date: 2018-07-04 14:55
AFAIU, the change for broke the following usage of subprocess on Windows (re-using a subprocess.STARTUPINFO instance to hide the command window):

    import os, subprocess

    STARTUPINFO.wShowWindow = subprocess.SW_HIDE

    # raises OSError: [WinError 87]
    # in the second loop iteration starting with Python 3.7
    for i in range(2):
        with open(os.devnull, 'w') as stderr:
            subprocess.check_call(['attrib'], stderr=stderr,

AFAICT, this works on Python 2.7, 3.4, 3.5, and 3.6

I think the documentation in

does not mention that every Popen call should be done with a fresh instance, so either the documentation needs to be changed, or the implementation (e.g. by deep-copying the instance).

See also
msg321131 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-07-05 20:54
New changeset 483422f57e5d8c8bf8820fec29fc9b96bb15d4ef by Victor Stinner in branch 'master':
bpo-34044: subprocess.Popen copies startupinfo (GH-8090)
msg321132 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-07-05 21:15
New changeset 29be3bd3c9aed0190e60096a603120cacda82375 by Victor Stinner in branch '3.7':
bpo-34044: subprocess.Popen copies startupinfo (GH-8090) (GH-8121)
msg321133 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-07-05 21:20
Sebastian Bank: Thank you for your bug report and your example! I used your example to write an unit test. I fixed the bug in 3.7 and master branches. The fix will be part of the future 3.7.1 release.
msg321138 - (view) Author: Sebastian Bank (xflr6) Date: 2018-07-05 22:27
Perfect, thanks for the quick fix.
Date User Action Args
2022-04-11 14:59:02adminsetgithub: 78225
2018-07-05 22:27:55xflr6setmessages: + msg321138
2018-07-05 21:20:00vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg321133

stage: patch review -> resolved
2018-07-05 21:15:37vstinnersetmessages: + msg321132
2018-07-05 20:59:20vstinnersetpull_requests: + pull_request7706
2018-07-05 20:54:47miss-islingtonsetpull_requests: + pull_request7705
2018-07-05 20:54:22vstinnersetmessages: + msg321131
2018-07-04 15:17:05vstinnersetversions: + Python 3.8
2018-07-04 15:16:56vstinnersetkeywords: + patch
stage: patch review
pull_requests: + pull_request7691
2018-07-04 14:55:46xflr6create