[issue17797] Visual C++ 11.0 reports fileno(stdin) == 0 for non-console program
Mateusz Loskot
report at bugs.python.org
Fri Apr 19 16:09:25 CEST 2013
Mateusz Loskot added the comment:
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/
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17797>
_______________________________________
More information about the Python-bugs-list
mailing list