Eryk Sun <eryk...@gmail.com> added the comment:

> What is the most trivial way to test it's behaviour?

With CREATE_NO_WINDOW, the child process is attached to a console that has no 
window. Thus calling GetConsoleWindow() in the child returns NULL without an 
error. OTOH, if the child has no console (e.g. DETACHED_PROCESS or executing 
"pythonw.exe"), then GetConsoleWindow() returns NULL with the last error set to 
ERROR_INVALID_HANDLE (6). For example:

    script = r'''
    import sys
    import ctypes
    kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)
    kernel32.GetConsoleWindow.restype = ctypes.c_void_p
    ctypes.set_last_error(0)
    result = kernel32.GetConsoleWindow()
    status = bool(result or ctypes.get_last_error())
    sys.exit(status)
    '''
    args = [sys.executable, '-c', script]

The child's exit status will be 0 if CREATE_NO_WINDOW works as expected. 
Otherwise the exit status will be 1.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue30082>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to