diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2014-05-08 17:26:04 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2014-05-08 17:26:04 (GMT) |
commit | b0acc1b0a35905fa8dc3d3d10581602b5129c87a (patch) | |
tree | fa146c6ee8b1af10f8d05f2c104c9ae7c69e68d7 /Lib | |
parent | 9ba90c9f06157bd17dc5ba569e3314832873f260 (diff) | |
download | cpython-b0acc1b0a35905fa8dc3d3d10581602b5129c87a.zip cpython-b0acc1b0a35905fa8dc3d3d10581602b5129c87a.tar.gz cpython-b0acc1b0a35905fa8dc3d3d10581602b5129c87a.tar.bz2 |
Issue #21350: Fix file.writelines() to accept arbitrary buffer objects, as advertised.
Patch by Brian Kearns.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_file2k.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_file2k.py b/Lib/test/test_file2k.py index 7e74e64..fae1db6 100644 --- a/Lib/test/test_file2k.py +++ b/Lib/test/test_file2k.py @@ -89,6 +89,13 @@ class AutoFileTests(unittest.TestCase): self.assertRaises(TypeError, self.f.writelines, [NonString(), NonString()]) + def testWritelinesBuffer(self): + self.f.writelines([array('c', 'abc')]) + self.f.close() + self.f = open(TESTFN, 'rb') + buf = self.f.read() + self.assertEqual(buf, 'abc') + def testRepr(self): # verify repr works self.assertTrue(repr(self.f).startswith("<open file '" + TESTFN)) |