summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-05-17 19:56:59 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-05-17 19:56:59 (GMT)
commit83137c2e16ab34ecfa9695ae976b2b36fda2a17a (patch)
treebde315c150480fc78cba19af523acb1207481d9c /Lib
parentaf87f9f09f264d64ca564efd6818a1d0d7248a31 (diff)
downloadcpython-83137c2e16ab34ecfa9695ae976b2b36fda2a17a.zip
cpython-83137c2e16ab34ecfa9695ae976b2b36fda2a17a.tar.gz
cpython-83137c2e16ab34ecfa9695ae976b2b36fda2a17a.tar.bz2
Issue #7079: Fix a possible crash when closing a file object while using
it from another thread. Patch by Daniel Stutzbach.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_file2k.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/Lib/test/test_file2k.py b/Lib/test/test_file2k.py
index accdc95..da2ab67 100644
--- a/Lib/test/test_file2k.py
+++ b/Lib/test/test_file2k.py
@@ -429,6 +429,7 @@ class FileThreadingTests(unittest.TestCase):
self._count_lock = threading.Lock()
self.close_count = 0
self.close_success_count = 0
+ self.use_buffering = False
def tearDown(self):
if self.f:
@@ -443,7 +444,10 @@ class FileThreadingTests(unittest.TestCase):
test_support.threading_cleanup(*self._threads)
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:
@@ -530,6 +534,12 @@ class FileThreadingTests(unittest.TestCase):
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)