[issue34577] imaplib Cyrillic password

2018-09-05 Thread Nikita Velykanov


Nikita Velykanov  added the comment:

It works. Thanks a lot!

--
stage:  -> resolved
status: open -> closed

___
Python tracker 
<https://bugs.python.org/issue34577>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34577] imaplib Cyrillic password

2018-09-04 Thread Nikita Velykanov


Nikita Velykanov  added the comment:

Thank you for fast reply.
Here's full traceback for first case:

Traceback (most recent call last):
  File "some_my_file.py", line 10, in some_function
self.mail.login(login, password)
  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)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 30-39: 
ordinal not in range(128)

Full traceback for second case:

Traceback (most recent call last):
  File "some_my_file.py", line 10, in some_function
self.mail.login(login, password)
  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))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 1: ordinal 
not in range(128)


But okay, even if encoding depends on target system and it's usually utf-8 so 
why string operations in imaplib are not in usual format but in some other?

--

___
Python tracker 
<https://bugs.python.org/issue34577>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34577] imaplib Cyrillic password

2018-09-04 Thread Nikita Velykanov

New submission from Nikita Velykanov :

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.

--
components: Library (Lib), Unicode
messages: 324586
nosy: Nikita Velykanov, ezio.melotti, vstinner
priority: normal
severity: normal
status: open
title: imaplib Cyrillic password
type: behavior
versions: Python 2.7

___
Python tracker 
<https://bugs.python.org/issue34577>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com