You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
subprocess: reusing STARTUPINFO breaks under 3.7 (Windows) #78225
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):
importos, subprocessSTARTUPINFO=subprocess.STARTUPINFO()
STARTUPINFO.dwFlags|=subprocess.STARTF_USESHOWWINDOWSTARTUPINFO.wShowWindow=subprocess.SW_HIDE# raises OSError: [WinError 87]# in the second loop iteration starting with Python 3.7foriinrange(2):
print(i)
withopen(os.devnull, 'w') asstderr:
subprocess.check_call(['attrib'], stderr=stderr,
startupinfo=STARTUPINFO)
AFAICT, this works on Python 2.7, 3.4, 3.5, and 3.6
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).
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.
Activity
xflr6 commentedon Jul 4, 2018
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):
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
vstinner commentedon Jul 5, 2018
New changeset 483422f by Victor Stinner in branch 'master':
bpo-34044: subprocess.Popen copies startupinfo (GH-8090)
483422f
vstinner commentedon Jul 5, 2018
New changeset 29be3bd by Victor Stinner in branch '3.7':
bpo-34044: subprocess.Popen copies startupinfo (GH-8090) (GH-8121)
29be3bd
vstinner commentedon Jul 5, 2018
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.
xflr6 commentedon Jul 5, 2018
Perfect, thanks for the quick fix.