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.

Author eryksun
Recipients eryksun, iMath, mmaswg, ohno, paul.moore, steve.dower, tim.golden, zach.ware
Date 2021-10-28.09:07:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1635412050.34.0.627790712488.issue30082@roundup.psfhosted.org>
In-reply-to
Content
> 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.
History
Date User Action Args
2021-10-28 09:07:30eryksunsetrecipients: + eryksun, paul.moore, tim.golden, zach.ware, steve.dower, iMath, ohno, mmaswg
2021-10-28 09:07:30eryksunsetmessageid: <1635412050.34.0.627790712488.issue30082@roundup.psfhosted.org>
2021-10-28 09:07:30eryksunlinkissue30082 messages
2021-10-28 09:07:30eryksuncreate