Mateusz Loskot added the comment: On 12 September 2013 00:06, Antoine Pitrou <rep...@bugs.python.org> wrote: >> Shortly, is_valid_fd always returns true because fd < 0 is always >> false as my tests with Visual Studio 2012 > > Well, that's not all there is, is_valid_fd() does other checks before > returning true.
Given the function: is_valid_fd(int fd) { int dummy_fd; if (fd < 0 || !_PyVerify_fd(fd)) return 0; dummy_fd = dup(fd); if (dummy_fd < 0) return 0; close(dummy_fd); return 1; } for fd values of 0, 1 or 2 1. fd < 0 is always false 2. _PyVerify_fd(fd) is always true. Given the current definition: #define _PyVerify_fd(fd) (_get_osfhandle(fd) >= 0) for those values of fd _get_osfhandle(fd) >= 0, always. 3. for those fd values, dup() never returns fd < 0 ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue17797> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com