diff options
author | Benjamin Peterson <benjamin@python.org> | 2010-10-16 19:20:12 +0000 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2010-10-16 19:20:12 +0000 |
commit | bf775542b0798afcde4f338aef73553636a9069b (patch) | |
tree | e2a3dff42add90c424c25c67ef405a1bd7a0ccd6 /Lib/test/test_file2k.py | |
parent | f76942d6bf432d6881dc47070002d226e1e15ce9 (diff) | |
download | cpython-git-bf775542b0798afcde4f338aef73553636a9069b.tar.gz |
iterators passed to writelines() can close their files; don't segfault #10125
Diffstat (limited to 'Lib/test/test_file2k.py')
-rw-r--r-- | Lib/test/test_file2k.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_file2k.py b/Lib/test/test_file2k.py index fc8bfe9c5d..ab09f2161b 100644 --- a/Lib/test/test_file2k.py +++ b/Lib/test/test_file2k.py @@ -135,6 +135,14 @@ class AutoFileTests(unittest.TestCase): def testReadWhenWriting(self): self.assertRaises(IOError, self.f.read) + def testNastyWritelinesGenerator(self): + def nasty(): + for i in range(5): + if i == 3: + self.f.close() + yield str(i) + self.assertRaises(ValueError, self.f.writelines, nasty()) + def testIssue5677(self): # Remark: Do not perform more than one test per open file, # since that does NOT catch the readline error on Windows. |