From: Menno Smits Date: Tue, 21 Jul 2015 02:18:26 +0000 (+1200) Subject: Undid some bogus unicode changes from early in this feature branch X-Git-Tag: 1.0.0~1^2~57^2~3 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=01a354ab1bbc822c6b60923d0822ce064ba26c98;p=imapclient.git Undid some bogus unicode changes from early in this feature branch The live tests indicated that these were wrong under Python 3. --- diff --git a/imapclient/imapclient.py b/imapclient/imapclient.py index 74e6c6f..79339ac 100644 --- a/imapclient/imapclient.py +++ b/imapclient/imapclient.py @@ -193,8 +193,8 @@ class IMAPClient(object): """ return self._command_and_check( 'login', - to_bytes(username), - to_bytes(password), + to_unicode(username), + to_unicode(password), unpack=True, ) @@ -349,7 +349,7 @@ class IMAPClient(object): decoded from modified UTF-7, except if folder_decode is not set. """ - return self._do_list(b'LIST', directory, pattern) + return self._do_list('LIST', directory, pattern) def xlist_folders(self, directory="", pattern="*"): """Execute the XLIST command, returning ``(flags, delimiter, @@ -382,7 +382,7 @@ class IMAPClient(object): The *directory* and *pattern* arguments are as per list_folders(). """ - return self._do_list(b'XLIST', directory, pattern) + return self._do_list('XLIST', directory, pattern) def list_sub_folders(self, directory="", pattern="*"): """Return a list of subscribed folders on the server as @@ -391,7 +391,7 @@ class IMAPClient(object): The default behaviour will list all subscribed folders. The *directory* and *pattern* arguments are as per list_folders(). """ - return self._do_list(b'LSUB', directory, pattern) + return self._do_list('LSUB', directory, pattern) def _do_list(self, cmd, directory, pattern): directory = self._normalise_folder(directory) @@ -687,7 +687,7 @@ class IMAPClient(object): if charset: args.extend([b'CHARSET', charset]) args.extend(criteria) - typ, data = self._imap.uid(b'SEARCH', *args) + typ, data = self._imap.uid('SEARCH', *args) else: typ, data = self._imap.search(charset, *criteria) diff --git a/imapclient/test/test_imapclient.py b/imapclient/test/test_imapclient.py index 4786925..87835d1 100644 --- a/imapclient/test/test_imapclient.py +++ b/imapclient/test/test_imapclient.py @@ -26,7 +26,7 @@ class TestListFolders(IMAPClientTest): folders = self.client.list_folders('foo', 'bar') self.client._imap._simple_command.assert_called_once_with( - b'LIST', b'"foo"', b'"bar"') + 'LIST', b'"foo"', b'"bar"') self.assertEqual(self.client._proc_folder_list.call_args, ((sentinel.folder_data,), {})) self.assertTrue(folders is sentinel.folder_list) @@ -38,7 +38,7 @@ class TestListFolders(IMAPClientTest): folders = self.client.list_sub_folders('foo', 'bar') self.client._imap._simple_command.assert_called_once_with( - b'LSUB', b'"foo"', b'"bar"') + 'LSUB', b'"foo"', b'"bar"') self.assertEqual(self.client._proc_folder_list.call_args, ((sentinel.folder_data,), {})) self.assertTrue(folders is sentinel.folder_list) @@ -55,14 +55,14 @@ class TestListFolders(IMAPClientTest): def test_utf7_decoding(self): self.client._imap._simple_command.return_value = ('OK', [b'something']) self.client._imap._untagged_response.return_value = ( - b'LIST', [ + 'LIST', [ b'(\\HasNoChildren) "/" "A"', b'(\\HasNoChildren) "/" "Hello&AP8-world"', ]) folders = self.client.list_folders('foo', 'bar') - self.client._imap._simple_command.assert_called_once_with(b'LIST', b'"foo"', b'"bar"') + self.client._imap._simple_command.assert_called_once_with('LIST', b'"foo"', b'"bar"') self.assertEqual(folders, [((b'\\HasNoChildren',), b'/', 'A'), ((b'\\HasNoChildren',), b'/', 'Hello\xffworld')]) @@ -70,14 +70,14 @@ class TestListFolders(IMAPClientTest): self.client.folder_encode = False self.client._imap._simple_command.return_value = ('OK', [b'something']) self.client._imap._untagged_response.return_value = ( - b'LIST', [ + 'LIST', [ b'(\\HasNoChildren) "/" "A"', b'(\\HasNoChildren) "/" "Hello&AP8-world"', ]) folders = self.client.list_folders('foo', 'bar') - self.client._imap._simple_command.assert_called_once_with(b'LIST', '"foo"', '"bar"') + self.client._imap._simple_command.assert_called_once_with('LIST', '"foo"', '"bar"') self.assertEqual(folders, [((b'\\HasNoChildren',), b'/', b'A'), ((b'\\HasNoChildren',), b'/', b'Hello&AP8-world')]) diff --git a/imapclient/test/test_search.py b/imapclient/test/test_search.py index 5558e72..fa4403f 100644 --- a/imapclient/test/test_search.py +++ b/imapclient/test/test_search.py @@ -16,7 +16,7 @@ class TestSearch(IMAPClientTest): result = self.client.search('FOO') - self.client._imap.uid.assert_called_once_with(b'SEARCH', '(FOO)') + self.client._imap.uid.assert_called_once_with('SEARCH', '(FOO)') self.assertEqual(result, [1, 2, 44]) self.assertEqual(result.modseq, None) @@ -26,7 +26,7 @@ class TestSearch(IMAPClientTest): result = self.client.search('FOO') - self.client._imap.uid.assert_called_once_with(b'SEARCH', '(FOO)') + self.client._imap.uid.assert_called_once_with('SEARCH', '(FOO)') self.assertEqual(result, []) self.assertEqual(result.modseq, None) @@ -47,7 +47,7 @@ class TestSearch(IMAPClientTest): result = self.client.search('FOO', 'UTF9') self.client._imap.uid.assert_called_once_with( - b'SEARCH', + 'SEARCH', b'CHARSET', 'UTF9', '(FOO)') self.assertEqual(result, [1, 2, 44]) @@ -75,7 +75,7 @@ class TestSearch(IMAPClientTest): result = self.client.search(['MODSEQ 40000']) - self.client._imap.uid.assert_called_once_with(b'SEARCH', '(MODSEQ 40000)') + self.client._imap.uid.assert_called_once_with('SEARCH', '(MODSEQ 40000)') self.assertEqual(result, [1, 2]) self.assertEqual(result.modseq, 51101) @@ -95,7 +95,7 @@ class TestGmailSearch(IMAPClientTest): result = self.client.gmail_search('FOO') - self.client._imap.uid.assert_called_once_with(b'SEARCH', b'X-GM-RAW') + self.client._imap.uid.assert_called_once_with('SEARCH', b'X-GM-RAW') self.assertEqual(self.client._imap.literal, b'FOO') self.assertEqual(result, [1, 2, 44]) @@ -116,7 +116,7 @@ class TestGmailSearch(IMAPClientTest): result = self.client.gmail_search('\u2620', 'UTF8') self.client._imap.uid.assert_called_once_with( - b'SEARCH', + 'SEARCH', b'CHARSET', 'UTF8', b'X-GM-RAW') self.assertEqual(self.client._imap.literal, b'\xe2\x98\xa0')