[bug] imaplib case sensitive

Petite Abeille petite.abeille at gmail.com
Tue Feb 21 10:31:36 CET 2012


Looks like imaplib is case sensitive, even though the IMAP protocol isn't:

(1) Except as noted otherwise, all alphabetic characters
        are case-insensitive.  The use of upper or lower case
        characters to define token strings is for editorial clarity
        only.  Implementations MUST accept these strings in a
        case-insensitive fashion.


For example:  

[Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) ]
[imaplib 2.58]

import imaplib

M = imaplib.IMAP4( 'localhost', 1143 )
M.login( 'user', 'password' )
typ, data = M.search(None, 'ALL')
for num in data[0].split():
    typ, data = M.fetch(num, '(ENVELOPE)')
    print 'Message %s\n%s\n' % (num, data[0][1])

Traceback (most recent call last):
  File "Test.py", line 3, in <module>
    M = imaplib.IMAP4( 'localhost', 1143 )
  File "python2.6/imaplib.py", line 184, in __init__
    self.welcome = self._get_response()
  File "python2.6/imaplib.py", line 935, in _get_response
    raise self.abort("unexpected response: '%s'" % resp)
imaplib.abort: unexpected response: '* ok imap4rev1'

Note the 'ok' tag in lower case.

More information about the Python-list mailing list