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 Nikita Velykanov
Recipients Nikita Velykanov, ezio.melotti, vstinner
Date 2018-09-04.14:11:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1536070305.76.0.56676864532.issue34577@psf.upfronthosting.co.za>
In-reply-to
Content
Let's consider there is an email box with password which contains Cyrillic symbols. When loging in

  imaplib.IMAP4_SSL(host, port).login(login, password)

password field is passed as "кириллица" (type is str, not unicode).
Then, I get this traceback:

  File "/usr/lib64/python2.7/imaplib.py", line 518, in login
    typ, dat = self._simple_command('LOGIN', user, self._quote(password))
  File "/usr/lib64/python2.7/imaplib.py", line 1083, in _simple_command
    return self._command_complete(name, self._command(name, *args))
  File "/usr/lib64/python2.7/imaplib.py", line 870, in _command
    self.send('%s%s' % (data, CRLF))
  File "/usr/lib64/python2.7/imaplib.py", line 1191, in send
    sent = self.sslobj.write(data)
  File "/usr/lib64/python2.7/ssl.py", line 669, in write
    return self._sslobj.write(data)

This is because self._sslobj.write method requires unicode string.

In other case, if password field is passed as u"кириллица" (type unicode, not str), I get another traceback:

  File "/usr/lib64/python2.7/imaplib.py", line 518, in login
    typ, dat = self._simple_command('LOGIN', user, self._quote(password))
  File "/usr/lib64/python2.7/imaplib.py", line 1083, in _simple_command
    return self._command_complete(name, self._command(name, *args))
  File "/usr/lib64/python2.7/imaplib.py", line 852, in _command
    data = '%s %s' % (data, self._checkquote(arg))

It's because '%s' % u"some unicode string" doesn't work.

I guess the problem was described in details.
The problem is that two different libraries are using different string types but they must be agreed.
History
Date User Action Args
2018-09-04 14:11:45Nikita Velykanovsetrecipients: + Nikita Velykanov, vstinner, ezio.melotti
2018-09-04 14:11:45Nikita Velykanovsetmessageid: <1536070305.76.0.56676864532.issue34577@psf.upfronthosting.co.za>
2018-09-04 14:11:45Nikita Velykanovlinkissue34577 messages
2018-09-04 14:11:45Nikita Velykanovcreate