Visitar URL original
Newer reply format for imap commands in imaplib.py · Issue #45085 · python/cpython · GitHub
The Wayback Machine - https://web.archive.org/web/20241216012035/https://github.com/python/cpython/issues/45085
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newer reply format for imap commands in imaplib.py #45085

Closed
ntai mannequin opened this issue Jun 12, 2007 · 5 comments
Closed

Newer reply format for imap commands in imaplib.py #45085

ntai mannequin opened this issue Jun 12, 2007 · 5 comments
Labels
stdlib Python modules in the Lib dir topic-email type-feature A feature request or enhancement

Comments

@ntai
Copy link
Mannequin

ntai mannequin commented Jun 12, 2007

BPO 1735509
Nosy @ericvsmith, @bitdancer
Files
  • foo.txt: A proposal request for imaplib.py enhancement
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2007-06-12.06:48:20.000>
    labels = ['type-feature', 'library']
    title = 'Newer reply format for imap commands in imaplib.py'
    updated_at = <Date 2014-02-03.19:43:31.543>
    user = 'https://bugs.python.org/ntai'

    bugs.python.org fields:

    activity = <Date 2014-02-03.19:43:31.543>
    actor = 'BreamoreBoy'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2007-06-12.06:48:20.000>
    creator = 'ntai'
    dependencies = []
    files = ['8292']
    hgrepos = []
    issue_num = 1735509
    keywords = ['patch']
    message_count = 5.0
    messages = ['55140', '55141', '116689', '116692', '116698']
    nosy_count = 3.0
    nosy_names = ['eric.smith', 'ntai', 'r.david.murray']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'test needed'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue1735509'
    versions = ['Python 2.7']

    @ntai
    Copy link
    Mannequin Author

    ntai mannequin commented Jun 12, 2007

    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.

    @ntai ntai mannequin added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Jun 12, 2007
    @ntai
    Copy link
    Mannequin Author

    ntai mannequin commented Jun 12, 2007

    I overlooked that IMAP4_SSL needs the same enhancement. IMAP4_SSL's constructor should look like as follows.

        def __init__(self, host = '', port = IMAP4_SSL_PORT, keyfile = None, certfile = None, response_format = 1):
            self.keyfile = keyfile
            self.certfile = certfile
            IMAP4.__init__(self, host, port, response_format)

    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Sep 17, 2010

    Is there any interest in the change proposed here? If not I'll close in a few weeks time. Note the patch does not include doc or unit test changes.

    @ericvsmith
    Copy link
    Member

    I'm not sure what "fetch command does not contain literal" means. If the OP can clarify, I'd be interested in this issue.

    @bitdancer
    Copy link
    Member

    Someday I intend to pay a constructive visit to imaplib, so yes please leave this open.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @iritkatriel iritkatriel closed this as not planned Won't fix, can't repro, duplicate, stale Apr 25, 2023
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir topic-email type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants