Show
Ignore:
Timestamp:
09/11/11 20:40:19 (6 months ago)
Author:
Menno Smits <menno@…>
Branch:
default
Message:

Fix incorrect msg_id for UID fetch when use_uid is False (#99)

Don't use the UID as the key for FETCH responses where use_uid is
False but UID is a fetch item. The UID was being used as the key
instead of the message sequence.

Location:
imapclient
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • imapclient/imapclient.py

    r277 r278  
    674674        self._checkok('fetch', typ, data) 
    675675        typ, data = self._imap._untagged_response(typ, data, 'FETCH') 
    676         return parse_fetch_response(data, self.normalise_times) 
     676        return parse_fetch_response(data, self.normalise_times, self.use_uid) 
    677677 
    678678    def append(self, folder, msg, flags=(), msg_time=None): 
  • imapclient/response_parser.py

    r265 r278  
    5252 
    5353 
    54 def parse_fetch_response(text, normalise_times=True): 
     54def parse_fetch_response(text, normalise_times=True, uid_is_key=True): 
    5555    """Pull apart IMAP FETCH responses as returned by imaplib. 
    5656 
     
    8787 
    8888            if word == 'UID': 
    89                 msg_id = _int_or_error(value, 'invalid UID') 
     89                uid = _int_or_error(value, 'invalid UID') 
     90                if uid_is_key: 
     91                    msg_id = uid 
     92                else: 
     93                    msg_data[word] = uid 
    9094            elif word == 'INTERNALDATE': 
    9195                msg_data[word] = _convert_INTERNALDATE(value, normalise_times) 
  • imapclient/test/test_response_parser.py

    r265 r278  
    198198 
    199199 
    200     def test_repeated_UID(self): 
    201         self.assertEquals(parse_fetch_response(['23 (UID 76 FOO 123 UID 76 GOO 321)']), 
    202                           {76: {'FOO': 123, 
    203                                 'GOO': 321, 
     200    def test_not_uid_is_key(self): 
     201        self.assertEquals(parse_fetch_response(['23 (UID 76)'], uid_is_key=False), 
     202                          {23: {'UID': 76, 
    204203                                'SEQ': 23}}) 
    205         self.assertEquals(parse_fetch_response(['23 (UID 76 FOO 123', 'UID 76 GOO 321)']), 
    206                           {76: {'FOO': 123, 
    207                                 'GOO': 321, 
    208                                 'SEQ': 23}}) 
    209  
    210204 
    211205    def test_bad_UID(self):