[Bug 428578] [NEW] python3's imaplib fails at login

debatem1 debatem1 at gmail.com
Sat Sep 12 20:16:01 UTC 2009


Public bug reported:

Binary package hint: python3.0

Using this code:

#! /usr/bin/env python3

import getpass, imaplib

M = imaplib.IMAP4_SSL("imap.gmail.com")
M.login(<username>, <password>)
M.select()
typ, data = M.search(None, 'ALL')
for num in data[0].split():
    typ, data = M.fetch(num, '(RFC822)')
    print('Message %s\n%s\n' % (num, data[0][1]))
M.close()
M.logout()


taken almost verbatim from the module docs (username and password redacted, obviously),
produces the following error:

Traceback (most recent call last):
  File "./imaptest.py", line 6, in <module>
    M.login(<username>, <password>)
  File "/usr/lib/python3.0/imaplib.py", line 514, in login
    typ, dat = self._simple_command('LOGIN', user, self._quote(password))
  File "/usr/lib/python3.0/imaplib.py", line 1072, in _quote
    arg = arg.replace(b'\\', b'\\\\')
TypeError: Can't convert 'bytes' object to str implicitly


Changing /usr/lib/python3.0 so that the _quote method reads as follows:

    def _quote(self, arg):

        arg = arg.replace('\\', '\\\\')
        arg = arg.replace('"', '\\"')

        return '"' + arg + '"'

seems to fix the issue. The issue does not appear in current code from
upstream.

** Affects: python3.0 (Ubuntu)
     Importance: Undecided
         Status: New

-- 
python3's imaplib fails at login
https://bugs.launchpad.net/bugs/428578
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
ubuntu-bugs at lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs




More information about the universe-bugs mailing list