New submission from STINNER Victor <vstin...@redhat.com>:

test.support.fd_count() has two implementation: list /proc/self/fd/ on Linux 
and FreeBSD, or check all file descriptors from 0 and MAXFD. The problem is 
that the two implementation don't give the same result...

List /proc/self/fd/ (used by default on Linux):

vstinner@apu$ ./python -c 'from test.support import fd_count; print(fd_count())'
4

Check all FD (I modified fd_count() to force using this implementation):

vstinner@apu$ ./python -c 'from test.support import fd_count; print(fd_count())'
3

On Linux and FreeBSD, listdir() opens internally a file descriptor to list the 
content of the /proc/self/fd/ directory. So the function should substract one 
to the result.

Attached PR fixes the issue.

----------
components: Tests
messages: 318734
nosy: pitrou, vstinner
priority: normal
severity: normal
status: open
versions: Python 2.7, Python 3.6, Python 3.7, Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33773>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to