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 mloskot
Recipients mloskot
Date 2013-04-19.12:18:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1366373912.56.0.138468709297.issue17797@psf.upfronthosting.co.za>
In-reply-to
Content
In pythonrun.c, there is function initstdio() with the following test:

static int
initstdio(void)
{
...
    /* Set sys.stdin */
    fd = fileno(stdin);
    /* Under some conditions stdin, stdout and stderr may not be connected
     * and fileno() may point to an invalid file descriptor. For example
     * GUI apps don't have valid standard streams by default.
     */
    if (fd < 0) {
#ifdef MS_WINDOWS
        std = Py_None;
        Py_INCREF(std);
#else
        goto error;
#endif
    }
    else {
...
}

This function is fails for non-console applications (i.e. MFC) built using Visual C++ 11.0 (Visual Studio 2012), becasue **strangely**, fileno(stdin) == 0, so this test results in false and Python initialisation routines attempt to setup streams.

Apparently, fileno(stdin) return value has changed between Visual C++ 10.0 (VS 2010)
and 11.0. The VC++ 10.0 reports fileno(stdin) == -2.
History
Date User Action Args
2013-04-19 12:18:32mloskotsetrecipients: + mloskot
2013-04-19 12:18:32mloskotsetmessageid: <1366373912.56.0.138468709297.issue17797@psf.upfronthosting.co.za>
2013-04-19 12:18:32mloskotlinkissue17797 messages
2013-04-19 12:18:32mloskotcreate