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.

classification
Title: test_closerange in test_os can crash the test suite
Type: behavior Stage:
Components: Tests Versions: Python 3.0
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: pitrou
Priority: critical Keywords: patch

Created on 2008-08-16 21:37 by pitrou, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test_closerange.patch pitrou, 2008-08-16 21:57
Messages (3)
msg71241 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2008-08-16 21:37
I've been trying to track down the following failure which very recently
has started to plague the py3k buildbots:

[...]
test_os
Traceback (most recent call last):
  File "./Lib/test/regrtest.py", line 1197, in <module>
    main()
  File "./Lib/test/regrtest.py", line 400, in main
    print(test)
  File
"/home/buildbot/slave/py-build/3.0.norwitz-amd64/build/Lib/io.py", line
1490, in write
    self.flush()
  File
"/home/buildbot/slave/py-build/3.0.norwitz-amd64/build/Lib/io.py", line
1455, in flush
    self.buffer.flush()
  File
"/home/buildbot/slave/py-build/3.0.norwitz-amd64/build/Lib/io.py", line
1071, in flush
    self._flush_unlocked()
  File
"/home/buildbot/slave/py-build/3.0.norwitz-amd64/build/Lib/io.py", line
1079, in _flush_unlocked
    n = self.raw.write(self._write_buf)
IOError: [Errno 9] Bad file descriptor


I've determined that the failure in writing to the raw stream underlying
stdout is caused by the fact that the file descriptor 0 has been closed
in test_os.test_closerange:

    def test_closerange(self):
        f = os.open(support.TESTFN, os.O_CREAT|os.O_RDWR)
        # close a fd that is open, and one that isn't
        os.closerange(f, f+2)

The problem arises when the call to os.open above returns 0. Normally 0
is the file descriptor underlying stdin, I don't know why it ends up
available for other uses, this would deserve investigation.

In the meantime, a way of circumventing this problem would be to rewrite
test_closerange in a saner way, such that closerange() doesn't try to
close important file descriptors.
msg71242 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2008-08-16 21:57
Here is a temptative patch. It should fix the problems with test_closerange.
msg71248 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2008-08-16 23:29
I've finally diagnosed the problem. test_buffer_is_readonly was opening
stdin's file descriptor again in raw mode, and closing it implicitly by
using "with". 

It should be fixed in r65731.

There's a justice: the test had been checked in by me.
History
Date User Action Args
2022-04-11 14:56:37adminsetgithub: 47821
2008-08-16 23:29:41pitrousetstatus: open -> closed
resolution: fixed
messages: + msg71248
2008-08-16 21:57:17pitrousetfiles: + test_closerange.patch
keywords: + patch
messages: + msg71242
2008-08-16 21:37:37pitroucreate