python3's imaplib fails at login
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
python3.0 (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
Binary package hint: python3.0
Using this code:
#! /usr/bin/env python3
import getpass, imaplib
M = imaplib.
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(
File "/usr/lib/
typ, dat = self._simple_
File "/usr/lib/
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.