Index: Lib/test/test_fileio.py =================================================================== --- Lib/test/test_fileio.py (revision 68294) +++ Lib/test/test_fileio.py (working copy) @@ -113,7 +113,16 @@ else: self.fail("Should have raised IOError") + def testClose(self): + # Open a file via os.open and attach the received filedescriptor + # to a FileIO object. When we pull the file from under the stream's + # feet, any operation like e.g. closing must fail. + fd = os.open(TESTFN, os.O_RDONLY) + s = _fileio._FileIO(fd) + os.close(fd) + self.assertRaises(IOError, s.close) + class OtherFileTests(unittest.TestCase): def testAbles(self):