This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: threading via uid method doesn't work in imaplib
Type: behavior Stage: test needed
Components: Library (Lib) Versions: Python 3.1, Python 3.2, Python 2.7, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: abhishek, georg.brandl, piers, pierslauder, r.david.murray, terry.reedy
Priority: normal Keywords: easy

Created on 2009-02-03 19:57 by abhishek, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (5)
msg81094 - (view) Author: abhishek (abhishek) Date: 2009-02-03 19:57
Hi,

IMAP commands in general can be either called directly or via the UID
command which basically returns the UIDs instead of message IDs.
Consider this example:

  02:23.02 > GDJB3 UID THREAD references UTF-8 (SEEN)
  02:23.02 < * THREAD (3)(2)(4)(1)
  02:23.02     matched r'\* (?P<type>[A-Z-]+)( (?P<data>.*))?' =>
('THREAD', ' (3)(2)(4)(1)', '(3)(2)(4)(1)')
  02:23.03 untagged_responses[THREAD] 0 += ["(3)(2)(4)(1)"]
  02:23.03 < GDJB3 OK Thread completed.
  02:23.03     matched r'(?P<tag>GDJB\d+) (?P<type>[A-Z]+) (?P<data>.*)'
=> ('GDJB3', 'OK', 'Thread completed.')
[None]

...


  02:59.22 > CNCF3 THREAD references UTF-8 (SEEN)
  02:59.23 < * THREAD (3)(2)(4)(1)
  02:59.23     matched r'\* (?P<type>[A-Z-]+)( (?P<data>.*))?' =>
('THREAD', ' (3)(2)(4)(1)', '(3)(2)(4)(1)')
  02:59.23 untagged_responses[THREAD] 0 += ["(3)(2)(4)(1)"]
  02:59.23 < CNCF3 OK Thread completed.
  02:59.23     matched r'(?P<tag>CNCF\d+) (?P<type>[A-Z]+) (?P<data>.*)'
=> ('CNCF3', 'OK', 'Thread completed.')
  02:59.23 untagged_responses[THREAD] => ['(3)(2)(4)(1)']
['(3)(2)(4)(1)']


The reason I figured out why UID failed whereas the direct method call
worked lies in this particular line of the method 'uid' in imaplib.py:

        if command in ('SEARCH', 'SORT'):
            name = command
        else:
            name = 'FETCH'

which should be :

        if command in ('SEARCH', 'SORT', 'THREAD'):
            name = command
        else:
            name = 'FETCH'

I was able to confirm this in both 2.4 and 2.5.

Hope this would be looked upon and fixed.

Regards,
Abhishek
msg81105 - (view) Author: Piers Lauder (piers) Date: 2009-02-03 21:56
I agree with this change.

It should be propagated to all versions.
msg108660 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-06-26 00:21
I confirmed that 3.1.2 has same 'old' text that the OP proposes to change. I cannot comment on the substance. Stage 'needs patch' means it needs a diff file. I do not know whether or how the imaplib is unit tested.
msg108681 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-06-26 02:31
A test suite skeleton was recently contributed; it's in the standard location (Lib/test/test_imaplib).
msg112221 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-07-31 22:33
Some research into IMAP commands confirms that this change is correct.  Done so in r83374.
History
Date User Action Args
2022-04-11 14:56:45adminsetgithub: 49396
2010-07-31 22:33:07georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg112221

resolution: fixed
2010-06-26 02:31:57r.david.murraysetnosy: + r.david.murray

messages: + msg108681
stage: needs patch -> test needed
2010-06-26 00:21:38terry.reedysetversions: + Python 2.6, Python 3.1, Python 2.7, Python 3.2, - Python 2.5, Python 2.4
nosy: + terry.reedy

messages: + msg108660

keywords: + easy
stage: needs patch
2009-02-03 21:56:18pierssetmessages: + msg81105
2009-02-03 19:57:35abhishekcreate