Changeset 278:f702a10af3d6
- 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:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r277
|
r278
|
|
| 674 | 674 | self._checkok('fetch', typ, data) |
| 675 | 675 | 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) |
| 677 | 677 | |
| 678 | 678 | def append(self, folder, msg, flags=(), msg_time=None): |
-
|
r265
|
r278
|
|
| 52 | 52 | |
| 53 | 53 | |
| 54 | | def parse_fetch_response(text, normalise_times=True): |
| | 54 | def parse_fetch_response(text, normalise_times=True, uid_is_key=True): |
| 55 | 55 | """Pull apart IMAP FETCH responses as returned by imaplib. |
| 56 | 56 | |
| … |
… |
|
| 87 | 87 | |
| 88 | 88 | 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 |
| 90 | 94 | elif word == 'INTERNALDATE': |
| 91 | 95 | msg_data[word] = _convert_INTERNALDATE(value, normalise_times) |
-
|
r265
|
r278
|
|
| 198 | 198 | |
| 199 | 199 | |
| 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, |
| 204 | 203 | '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 | | |
| 210 | 204 | |
| 211 | 205 | def test_bad_UID(self): |