Patch 1329 (partial) by Christian Heimes.
Add a closefd flag to open() which can be set to False to prevent closing
the file descriptor when close() is called or when the object is destroyed.
Useful to ensure that sys.std{in,out,err} keep their file descriptors open
when Python is uninitialized. (This was always a feature in 2.x, it just
wasn't implemented in 3.0 yet.)
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index e826ff4..9d4163e 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -259,6 +259,9 @@
self.assertEqual(f.write(a), n)
f.close()
+ def test_closefd(self):
+ self.assertRaises(ValueError, io.open, test_support.TESTFN, 'w',
+ closefd=False)
class MemorySeekTestMixin: