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 amaury.forgeotdarc, mloskot
Date 2013-04-19.14:09:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1366380565.38.0.815023617781.issue17797@psf.upfronthosting.co.za>
In-reply-to
Content
Replacing if the current test in Python 3.2

if (fd < 0)
with
if (check_fd(fd) < 0)

Seems to be a working solution.

I just noticed, that in current Python/pythonrun.c in the repo, there the fd < 0 tests have been replaced with new function is_valid_fd(). But, its semantic is equivalent to fd < 0, so it does not check anything really. Perhaps is_valid_fd could be redefined as check_fd.

Here are Visual C++ 11.0 (1700) vs 10.0 differences of fileno return value for all the standard streams

    int fdi, fdo, fde;
    fdi = fileno(stdin);
    fdo = fileno(stdout);
    fde = fileno(stderr);
#if _MSC_VER < 1700
    assert(fdi == -2);
    assert(fdo == -2);
    assert(fde == -2);
#else
    assert(fdi == 0);
    assert(fdo == 1);
    assert(fde == 2);
#endif

By the way, I assume such sudden change in fileno(std*) behaviour between Visual C++ versions is suspicious, so I also submitted bug report to Visual Studio:
https://connect.microsoft.com/VisualStudio/feedback/details/785119/
History
Date User Action Args
2013-04-19 14:09:25mloskotsetrecipients: + mloskot, amaury.forgeotdarc
2013-04-19 14:09:25mloskotsetmessageid: <1366380565.38.0.815023617781.issue17797@psf.upfronthosting.co.za>
2013-04-19 14:09:25mloskotlinkissue17797 messages
2013-04-19 14:09:25mloskotcreate