Merged revisions 81275 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r81275 | antoine.pitrou | 2010-05-17 21:56:59 +0200 (lun., 17 mai 2010) | 4 lines
Issue #7079: Fix a possible crash when closing a file object while using
it from another thread. Patch by Daniel Stutzbach.
........
diff --git a/Lib/test/test_file.py b/Lib/test/test_file.py
index c5e5ea1..d77fb42 100644
--- a/Lib/test/test_file.py
+++ b/Lib/test/test_file.py
@@ -417,6 +417,7 @@
self._count_lock = threading.Lock()
self.close_count = 0
self.close_success_count = 0
+ self.use_buffering = False
def tearDown(self):
if self.f:
@@ -430,7 +431,10 @@
pass
def _create_file(self):
- self.f = open(self.filename, "w+")
+ if self.use_buffering:
+ self.f = open(self.filename, "w+", buffering=1024*16)
+ else:
+ self.f = open(self.filename, "w+")
def _close_file(self):
with self._count_lock:
@@ -517,6 +521,12 @@
print >> self.f, ''
self._test_close_open_io(io_func)
+ def test_close_open_print_buffered(self):
+ self.use_buffering = True
+ def io_func():
+ print >> self.f, ''
+ self._test_close_open_io(io_func)
+
def test_close_open_read(self):
def io_func():
self.f.read(0)