From ed3a303548ba08aac44176b4566efa2f3bc0db66 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 2 Apr 2013 22:13:27 +0200 Subject: [PATCH] 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) --- Lib/test/test_ftplib.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Lib/test/test_ftplib.py b/Lib/test/test_ftplib.py index 824b7c123b4..6a6516517f8 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])