classification
Title: subprocess.check_output opens an unwanted command line window after fall creator update
Type: behavior Stage:
Components: Windows Versions: Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Christian Heigele, eryksun, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2018-02-09 10:52 by Christian Heigele, last changed 2018-02-12 09:44 by Christian Heigele.

Messages (10)
msg311875 - (view) Author: Christian Heigele (Christian Heigele) Date: 2018-02-09 10:52
Hi,

I have two machines, both Windows 10, both with python 2.7.12 (bug is also reproducible with 2.7.14), one of them has the Fall creator update (-> version 1709) and one doesn't (->version 1607). 

When I execute the checkout on some executable that is available on both machines, I get different behaviours: One the one without the fall creator update I get the output of that executable as expected as the return value. One the machine with the update I see a new command line window popping up, the executable runs through, and the return value of check_output is an empty string.

I'll use it like follow:

f = subprocess.check_output(['svn.exe', '--help'])
msg311886 - (view) Author: Eryk Sun (eryksun) * Date: 2018-02-09 14:23
Is it just for this particular svn.exe application, or is it for any application (e.g. tasklist.exe)? 

The symptoms sound like svn.exe is spawning a new instance of itself with the `CREATE_NEW_CONSOLE` creation flag, which allocates a new console and replaces the standard handles if they aren't explicitly set by STARTUPINFO. svn.exe could be doing this indirectly via ShellExecute[Ex] in order to elevate via the "runas" verb. Try running Python elevated (run as administrator), in which case svn.exe may behave normally.
msg311887 - (view) Author: Christian Heigele (Christian Heigele) Date: 2018-02-09 15:04
That sounds like a hint in the right direction, for tasklist and also other non-windows tools, e.g. git the check_output works fine.

Starting it in an administrator prompt however didn't change the behaviour.
msg311888 - (view) Author: Christian Heigele (Christian Heigele) Date: 2018-02-09 15:13
Fiy: If I explicitly parse the creationflag CREATE_NEW_CONSOLE I see the window popping up on both machines, but only on one I get the correctly filled output.

process = subprocess.Popen(['svn.exe', '--help'], stdout=subprocess.PIPE, creationflags=subprocess.CREATE_NEW_CONSOLE)
msg311889 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2018-02-09 15:17
More likely it's set to use the WINDOWS subsystem and the allocates the console when it detects you've passed --help.

Is this the regular build of SVN or from one of the GUI tools?
msg311890 - (view) Author: Christian Heigele (Christian Heigele) Date: 2018-02-09 15:24
@Steve:

It's the command line variant delivered with tortoiseSvn, and it happens both in 1.9.7 and 1.9.5

Also it occurs not only with --help but also with the other svn arguments, e.g. up
msg311891 - (view) Author: Eryk Sun (eryksun) * Date: 2018-02-09 15:39
Setting CREATE_NEW_CONSOLE in Python isn't the same since Popen explicitly sets the standard handles via STARTUPINFO.

I installed TortoiseSVN-1.9.7.27907-x64-svn-1.9.7.msi in Windows 10 release 1709, but I can't reproduce your issue. Does it work correctly for you in the command prompt?
msg311894 - (view) Author: Christian Heigele (Christian Heigele) Date: 2018-02-09 16:01
@Erik: That looks exactly like my setup, too bad that it's not reproducible:(. I'll try to find other machines in my company that also have the 1709 update already installed, and try to reproduce it there.
msg312031 - (view) Author: Christian Heigele (Christian Heigele) Date: 2018-02-12 07:31
Confirmed. On my private machine I just got the 1709 update and also don't have the error. 

Any further ideas what I can do?
msg312034 - (view) Author: Christian Heigele (Christian Heigele) Date: 2018-02-12 09:44
Please stop investigation on this bug for now, it might be related to an in-house security tool.
History
Date User Action Args
2018-02-12 09:44:47Christian Heigelesetmessages: + msg312034
2018-02-12 07:31:26Christian Heigelesetmessages: + msg312031
2018-02-09 16:01:03Christian Heigelesetmessages: + msg311894
2018-02-09 15:39:36eryksunsetmessages: + msg311891
2018-02-09 15:24:48Christian Heigelesetmessages: + msg311890
2018-02-09 15:17:18steve.dowersetmessages: + msg311889
2018-02-09 15:13:18Christian Heigelesetmessages: + msg311888
2018-02-09 15:04:21Christian Heigelesetmessages: + msg311887
2018-02-09 14:23:26eryksunsettype: behavior

messages: + msg311886
nosy: + eryksun
2018-02-09 10:52:11Christian Heigelecreate