Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4489e92

Browse files
committed
(Merge 3.3) Close #6822: ftplib.FTP.storlines() expects a binary file, not a text file
Add an unit test to ensure that text files are rejectect (with TypeError)
2 parents d9ebf4d + ed3a303 commit 4489e92

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

Lib/test/test_ftplib.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,10 @@ def test_storlines(self):
588588
self.client.storlines('stor foo', f, callback=lambda x: flag.append(None))
589589
self.assertTrue(flag)
590590

591+
f = io.StringIO(RETR_DATA.replace('\r\n', '\n'))
592+
# storlines() expects a binary file, not a text file
593+
self.assertRaises(TypeError, self.client.storlines, 'stor foo', f)
594+
591595
def test_nlst(self):
592596
self.client.nlst()
593597
self.assertEqual(self.client.nlst(), NLST_DATA.split('\r\n')[:-1])

0 commit comments

Comments
 (0)