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.

Author debatem1
Recipients debatem1
Date 2009-09-12.20:05:56
SpamBayes Score 2.030609e-11
Marked as misclassified No
Message-id <1252785958.65.0.870328470051.issue6897@psf.upfronthosting.co.za>
In-reply-to
Content
Getting the following issue- 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 documentation, produces this 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

username and password obviously redeacted.

Changing imaplib.py's _quote function to this:

    def _quote(self, arg):

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

        return '"' + arg + '"'

seems to resolve the issue.
History
Date User Action Args
2009-09-12 20:05:58debatem1setrecipients: + debatem1
2009-09-12 20:05:58debatem1setmessageid: <1252785958.65.0.870328470051.issue6897@psf.upfronthosting.co.za>
2009-09-12 20:05:57debatem1linkissue6897 messages
2009-09-12 20:05:56debatem1create