Closed e3cd80c0-0d1c-412a-b4b4-5e542ba3ba75 closed 14 years ago
Getting the following issue- this code:
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.
Looks like duplicate of bpo-6734.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields: ```python assignee = None closed_at =
created_at =
labels = ['type-bug', 'library']
title = 'imaplib fails during login'
updated_at =
user = 'https://bugs.python.org/debatem1'
```
bugs.python.org fields:
```python
activity =
actor = 'r.david.murray'
assignee = 'none'
closed = True
closed_date =
closer = 'r.david.murray'
components = ['Library (Lib)']
creation =
creator = 'debatem1'
dependencies = []
files = []
hgrepos = []
issue_num = 6897
keywords = []
message_count = 2.0
messages = ['92552', '92593']
nosy_count = 2.0
nosy_names = ['marcin.bachry', 'debatem1']
pr_nums = []
priority = 'normal'
resolution = 'duplicate'
stage = 'resolved'
status = 'closed'
superseder = '6734'
type = 'behavior'
url = 'https://bugs.python.org/issue6897'
versions = ['Python 3.0']
```