Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-33773: Fix test.support.fd_count() on Linux/FreBSD #7421

Merged
merged 4 commits into from
Jun 6, 2018
Merged

bpo-33773: Fix test.support.fd_count() on Linux/FreBSD #7421

merged 4 commits into from
Jun 6, 2018

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Jun 5, 2018

Substract one because listdir() opens internally a file
descriptor to list the content of the /proc/self/fd/ directory.

https://bugs.python.org/issue33773

Substract one because listdir() opens internally a file
descriptor to list the content of the /proc/self/fd/ directory.
Move also MAXFD code before msvcrt.CrtSetReportMode(), to make sure
that the report mode is always restored on failure.
@vstinner
Copy link
Member Author

vstinner commented Jun 6, 2018

Oh... the test failed on Travis CI:

======================================================================
FAIL: test_fd_count (test.test_support.TestSupport)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/python/cpython/Lib/test/test_support.py", line 583, in test_fd_count
    self.assertEqual(out, "3")
AssertionError: '4' != '3'
- 4
+ 3

@vstinner
Copy link
Member Author

vstinner commented Jun 6, 2018

Oh... the test failed on Travis CI:

"import test.support" indirectly imports the random module, and this import calls os.urandom(). On old Linx kernel/glibc, Python keeps a FD open on the /dev/urandom device...

I rewrote the test to only see a difference, not test the absolute value.

@vstinner vstinner merged commit 492d642 into python:master Jun 6, 2018
@vstinner vstinner deleted the fd_count_one branch June 6, 2018 15:23
@miss-islington
Copy link
Contributor

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 2.7.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-7454 is a backport of this pull request to the 3.6 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 6, 2018
Substract one because listdir() opens internally a file
descriptor to list the content of the /proc/self/fd/ directory.

Add test_support.test_fd_count().

Move also MAXFD code before msvcrt.CrtSetReportMode(), to make sure
that the report mode is always restored on failure.
(cherry picked from commit 492d642)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 6, 2018
Substract one because listdir() opens internally a file
descriptor to list the content of the /proc/self/fd/ directory.

Add test_support.test_fd_count().

Move also MAXFD code before msvcrt.CrtSetReportMode(), to make sure
that the report mode is always restored on failure.
(cherry picked from commit 492d642)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
@bedevere-bot
Copy link

GH-7455 is a backport of this pull request to the 3.7 branch.

@miss-islington
Copy link
Contributor

Sorry, @vstinner, I could not cleanly backport this to 2.7 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 492d6424a7ca907c8ec1df21e51062e8f3d88e32 2.7

@bedevere-bot
Copy link

GH-7456 is a backport of this pull request to the 2.7 branch.

miss-islington added a commit that referenced this pull request Jun 6, 2018
Substract one because listdir() opens internally a file
descriptor to list the content of the /proc/self/fd/ directory.

Add test_support.test_fd_count().

Move also MAXFD code before msvcrt.CrtSetReportMode(), to make sure
that the report mode is always restored on failure.
(cherry picked from commit 492d642)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
miss-islington added a commit that referenced this pull request Jun 6, 2018
Substract one because listdir() opens internally a file
descriptor to list the content of the /proc/self/fd/ directory.

Add test_support.test_fd_count().

Move also MAXFD code before msvcrt.CrtSetReportMode(), to make sure
that the report mode is always restored on failure.
(cherry picked from commit 492d642)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
vstinner added a commit that referenced this pull request Jun 6, 2018
…7456)

Substract one because listdir() opens internally a file
descriptor to list the content of the /proc/self/fd/ directory.

Add test_support.test_fd_count().

Move also MAXFD code before msvcrt.CrtSetReportMode(), to make sure
that the report mode is always restored on failure.

(cherry picked from commit 492d642)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants