This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: test_os TestInvalidFD.test_closerange causes test_pipes hang in certain circumstances on linux
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.1, Python 3.2, Python 2.7, Python 2.6
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: r.david.murray Nosy List: alexandre.vassalotti, r.david.murray
Priority: normal Keywords: patch

Created on 2009-07-22 02:32 by r.david.murray, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
issue6542.patch r.david.murray, 2009-07-22 03:39
Messages (7)
msg90791 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-07-22 02:32
The test sequence "test_ttk_guionly test_os test_pipes" hangs almost
every time when run on Gentoo x86 and Ubuntu x86_64 (at least).  Note
that this is without the gui resource, so the ttk tests aren't being run.

Commenting out test_closerange in TestInvalidFD in test_os clears the
hang.  Playing around with which module imports are commented out in
test_ttk_guionly can clear the hang, but test_pipes then produces the
following errors:

ERROR: testSimplePipe1 (test.test_pipes.SimplePipeTests)
Traceback (most recent call last):
  File "/home/rdmurray/python/py3k/Lib/test/", line 23, in
    f =, 'w')
  File "/home/rdmurray/python/py3k/Lib/", line 148, in open
    return self.open_w(file)
  File "/home/rdmurray/python/py3k/Lib/", line 168, in open_w
    return os.popen(cmd, 'w')
  File "/home/rdmurray/python/py3k/Lib/", line 636, in popen
  File "/home/rdmurray/python/py3k/Lib/", line 646, in __init__
    errread, errwrite)
  File "/home/rdmurray/python/py3k/Lib/", line 1138, in
OSError: [Errno 9] Bad file descriptor

FAIL: testSimplePipe2 (test.test_pipes.SimplePipeTests)
Traceback (most recent call last):
  File "/home/rdmurray/python/py3k/Lib/test/", line 33, in
    self.assertEqual(open(TESTFN2).read(), 'HELLO WORLD #2')
AssertionError: '' != 'HELLO WORLD #2'

The first of these appears almost every time, the second one seldom. 
Occasinally both tests pass.
msg90793 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-07-22 02:45
It appears that TestInvalidFD.test_closerange is in fact closing a valid
file descriptor in this case.  I'm not sure how to fix the test...nor
why the close produced the results it does.
msg90796 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-07-22 03:10
Here's another buildbot failure that's probably the same thing:
msg90799 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-07-22 03:39
Patch to skip test if it can't get a range of invalid file descriptors
to test.  The test sequence passes with this patch in place.
msg90801 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2009-07-22 04:07
Oh, nice catch. That patch looks fine. However, I would probably add a
comment why the fstat checks are required.
msg90816 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-07-22 15:33
Applied in r74171 to py3k and r74172 to 3.1.

It occurs to me that I should backport this to trunk, so I'm leaving the
issue open until I do that.
msg90818 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-07-22 18:30
Backported to trunk in r74175, and 2.6 in r74176.
Date User Action Args
2022-04-11 14:56:51adminsetgithub: 50791
2009-07-22 18:30:52r.david.murraysetstatus: open -> closed

messages: + msg90818
2009-07-22 15:33:43r.david.murraysetresolution: fixed
stage: patch review -> resolved
messages: + msg90816
versions: + Python 2.6, Python 2.7
2009-07-22 04:07:39alexandre.vassalottisetnosy: + alexandre.vassalotti
messages: + msg90801
2009-07-22 03:39:59r.david.murraysetfiles: + issue6542.patch
messages: + msg90799

assignee: r.david.murray
keywords: + patch
stage: needs patch -> patch review
2009-07-22 03:10:22r.david.murraysetmessages: + msg90796
2009-07-22 02:45:14r.david.murraysetmessages: + msg90793
2009-07-22 02:32:02r.david.murraycreate