Message197509
On 12 September 2013 00:06, Antoine Pitrou <report@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 |
|
Date |
User |
Action |
Args |
2013-09-11 23:49:27 | mloskot | set | recipients:
+ mloskot, tim.peters, amaury.forgeotdarc, pitrou, vstinner, christian.heimes, tim.golden, brian.curtin, V.E.O, m_python |
2013-09-11 23:49:27 | mloskot | link | issue17797 messages |
2013-09-11 23:49:27 | mloskot | create | |
|