[ python-Feature Requests-1735509 ] Newer reply format for imap commands in imaplib.py

SourceForge.net noreply at sourceforge.net
Tue Jun 12 08:48:20 CEST 2007


Feature Requests item #1735509, was opened at 2007-06-12 02:48
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1735509&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Naoyuki Tai (ntai)
Assigned to: Nobody/Anonymous (nobody)
Summary: Newer reply format for imap commands in imaplib.py

Initial Comment:
If the fetch command does not contain literal, the result is

[ '1 (FLAGS (\\Seen) UID 1 RFC822.SIZE 26435)',
 '2 (FLAGS (\\Seen) UID 1 RFC822.SIZE 26435)']

If the fetch command contains literal, the result is

[ ('1 (FLAGS (\\Seen) UID 1 RFC822.SIZE 26435', 'header literal'),
 ')',
 ('2 (FLAGS (\\Seen) UID 1 RFC822.SIZE 26435', 'header literal'),
 ')']

First off, the number of elements in the reply becomes twice of non-literal fetch command.

Secondly, to parse the attribute string like "(FLAGS (\\Seen) UID 1 RFC822.SIZE 26435)" , one must check the first and last character to be '(' and ')' for the correctness of reply.

With the second type of reply / the reply with literal,  the reply string needs to be reconstructed out of the first element of tuple in an element, the subsequent element by appending them.

If the number of elements in the reply matches with the number of mails fetched, I can deal with the reply a lot easier.

As the shape of fetch command output is very different depending on literal, the use of fetch() is too hard for its good.

Therefore, I propose the new response format.
fetch_status, [ entry1, entry2, entry3, ... ]

And each entry is
[entry-reply]
or
[entry-reply, [literals]]

This allows that you can get to the entry reply uniformly regardless of whether or not the query of fetch with or without literal response.

Since the proposed response format is not compatible with existing format, additional proposal is to let the user of imaplib.py to designate the response format, as existing format as 1, and the new format as 2.

I have attached a patch for the proposed change.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1735509&group_id=5470


More information about the Python-bugs-list mailing list