Issue 34044: subprocess: reusing STARTUPINFO breaks under 3.7 (Windows) (original) (raw)

Issue34044

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 https://bugs.python.org/issue19764 broke the following usage of subprocess on Windows (re-using a subprocess.STARTUPINFO instance to hide the command window): import os, subprocess STARTUPINFO = subprocess.STARTUPINFO() STARTUPINFO.dwFlags |= subprocess.STARTF_USESHOWWINDOW STARTUPINFO.wShowWindow = subprocess.SW_HIDE # raises OSError: [WinError 87] # in the second loop iteration starting with Python 3.7 for i in range(2): print(i) with open(os.devnull, 'w') as stderr: subprocess.check_call(['attrib'], stderr=stderr, startupinfo=STARTUPINFO) AFAICT, this works on Python 2.7, 3.4, 3.5, and 3.6 I think the documentation in https://docs.python.org/3/library/subprocess.html#windows-popen-helpers 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 https://bugs.python.org/issue19764#msg320784
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) https://github.com/python/cpython/commit/483422f57e5d8c8bf8820fec29fc9b96bb15d4ef
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) https://github.com/python/cpython/commit/29be3bd3c9aed0190e60096a603120cacda82375
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.
History
Date User Action Args
2022-04-11 14:59:02 admin set github: 78225
2018-07-05 22:27:55 xflr6 set messages: +
2018-07-05 21:20:00 vstinner set status: open -> closedresolution: fixedmessages: + stage: patch review -> resolved
2018-07-05 21:15:37 vstinner set messages: +
2018-07-05 20:59:20 vstinner set pull_requests: + <pull%5Frequest7706>
2018-07-05 20:54:47 miss-islington set pull_requests: + <pull%5Frequest7705>
2018-07-05 20:54:22 vstinner set messages: +
2018-07-04 15:17:05 vstinner set versions: + Python 3.8
2018-07-04 15:16:56 vstinner set keywords: + patchstage: patch reviewpull_requests: + <pull%5Frequest7691>
2018-07-04 14:55:46 xflr6 create