Message92552
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. |
|
| Date |
User |
Action |
Args |
| 2009-09-12 20:05:58 | debatem1 | set | recipients:
+ debatem1 |
| 2009-09-12 20:05:58 | debatem1 | set | messageid: <1252785958.65.0.870328470051.issue6897@psf.upfronthosting.co.za> |
| 2009-09-12 20:05:57 | debatem1 | link | issue6897 messages |
| 2009-09-12 20:05:56 | debatem1 | create | |
|