From: Victor Stinner Date: Tue, 2 Apr 2013 20:13:27 +0000 (+0200) Subject: Close #6822: ftplib.FTP.storlines() expects a binary file, not a text file X-Git-Tag: v3.3.2~179 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ed3a303548ba08aac44176b4566efa2f3bc0db66;p=python 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) --- diff --git a/Lib/test/test_ftplib.py b/Lib/test/test_ftplib.py index 824b7c123b..6a6516517f 100644 --- a/Lib/test/test_ftplib.py +++ b/Lib/test/test_ftplib.py @@ -588,6 +588,10 @@ class TestFTPClass(TestCase): self.client.storlines('stor foo', f, callback=lambda x: flag.append(None)) self.assertTrue(flag) + f = io.StringIO(RETR_DATA.replace('\r\n', '\n')) + # storlines() expects a binary file, not a text file + self.assertRaises(TypeError, self.client.storlines, 'stor foo', f) + def test_nlst(self): self.client.nlst() self.assertEqual(self.client.nlst(), NLST_DATA.split('\r\n')[:-1])