]> khamidou — GitHub mirrors - imapclient.git/commitdiff
Handle [None] response in fetch response parser
authorMenno Smits <menno@freshfoo.com>
Fri, 14 Jan 2011 13:42:24 +0000 (13:42 +0000)
committerMenno Smits <menno@freshfoo.com>
Fri, 14 Jan 2011 13:42:24 +0000 (13:42 +0000)
imapclient/imapclient.py
imapclient/response_parser.py
imapclient/test/test_response_parser.py

index fc3044be51d50e2d9ddf8908fd0b6685a1bd54bf..092c6729a0a5fef1addba0808699ee2854357bc9 100644 (file)
@@ -507,11 +507,6 @@ class IMAPClient(object):
         typ, data = self._imap._command_complete('FETCH', tag)
         self._checkok('fetch', typ, data)
         typ, data = self._imap._untagged_response(typ, data, 'FETCH')
-        # appears to be a special case - no 'untagged' responses (ie, no
-        # folders) results in [None]
-        if data == [None]:
-          return {}
-
         return parse_fetch_response(data)
 
 
@@ -637,7 +632,6 @@ class IMAPClient(object):
         else:
             typ, data = self._imap.store(msg_list, cmd, flag_list)
         self._checkok('store', typ, data)
-
         return self._flatten_dict(parse_fetch_response((data)))
 
 
index 313dd37bab65662ce9b952518875b6243ff2434c..aeba9e036a73f2ec03575735302119bbac6c4e9b 100644 (file)
@@ -49,6 +49,8 @@ def parse_fetch_response(text):
     Returns a dictionary, keyed by message ID. Each value a dictionary
     keyed by FETCH field type (eg."RFC822").
     """
+    if text == [None]:
+        return {}
     response = gen_parsed_response(text)
 
     parsed_response = {}
index 951e22700a743a421f26f5dcab262b4173c93f1b..e0461581437132a19a0d8e76ff795260a32558d2 100644 (file)
@@ -204,6 +204,10 @@ class TestParseFetchResponse(unittest.TestCase):
         self.assertEquals(parse_fetch_response('4 ()'), {4: {'SEQ': 4}})
 
 
+    def test_none_special_case(self):
+        self.assertEquals(parse_fetch_response([None]), {})
+
+
     def test_bad_msgid(self):
         self.assertRaises(ParseError, parse_fetch_response, ['abc ()'])