New submission from Michal Niklas:

I have application that import emails from client IMAP4 mailboxes on home.pl (I 
think it is popular provider in Poland). It worked very well up to Python 2.7.9 
but with version 2.7.10 it hangs on read() in imaplib.IMAP4_SSL().

On my Fedora 23 I have Python 3.4.3 and 2.7.10.

With Python 3.4.3 such code works as expected:

        [mn] python3 -c "import imaplib; x=imaplib.IMAP4_SSL('imap.home.pl', 
993); print('finish', x)"
        finish <imaplib.IMAP4_SSL object at 0x7f80cfd31710>

But with Python 2.7.10 it hangs. I pressed Ctrl-C after few seconds:

        [mn] python -c "import imaplib; x=imaplib.IMAP4_SSL('imap.home.pl', 
993); print('finish', x)"
        ^CTraceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/usr/lib64/python2.7/imaplib.py", line 1166, in __init__
                IMAP4.__init__(self, host, port)
          File "/usr/lib64/python2.7/imaplib.py", line 202, in __init__
                typ, dat = self.capability()
          File "/usr/lib64/python2.7/imaplib.py", line 374, in capability
                typ, dat = self._simple_command(name)
          File "/usr/lib64/python2.7/imaplib.py", line 1088, in _simple_command
                return self._command_complete(name, self._command(name, *args))
          File "/usr/lib64/python2.7/imaplib.py", line 910, in _command_complete
                typ, data = self._get_tagged_response(tag)
          File "/usr/lib64/python2.7/imaplib.py", line 1017, in 
_get_tagged_response
                self._get_response()
          File "/usr/lib64/python2.7/imaplib.py", line 929, in _get_response
                resp = self._get_line()
          File "/usr/lib64/python2.7/imaplib.py", line 1027, in _get_line
                line = self.readline()
          File "/usr/lib64/python2.7/imaplib.py", line 1189, in readline
                return self.file.readline()
          File "/usr/lib64/python2.7/socket.py", line 451, in readline
                data = self._sock.recv(self._rbufsize)
          File "/usr/lib64/python2.7/ssl.py", line 734, in recv
                return self.read(buflen)
          File "/usr/lib64/python2.7/ssl.py", line 621, in read
                v = self._sslobj.read(len or 1024)
        KeyboardInterrupt

You can also test it with docker to see that it worked with older versions of 
Python:

        [mn] sudo docker run --rm -it python:2.7.9 python -c "import imaplib; 
x=imaplib.IMAP4_SSL('imap.home.pl', 993); print('finish', x)"
        ('finish', <imaplib.IMAP4_SSL instance at 0x7f682422b2d8>)

        [mn] sudo docker run --rm -it python:2.7.10 python -c "import imaplib; 
x=imaplib.IMAP4_SSL('imap.home.pl', 993); print('finish', x)"
        ^CTraceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/usr/local/lib/python2.7/imaplib.py", line 1166, in __init__
                IMAP4.__init__(self, host, port)
          File "/usr/local/lib/python2.7/imaplib.py", line 202, in __init__
                typ, dat = self.capability()
          File "/usr/local/lib/python2.7/imaplib.py", line 374, in capability
                typ, dat = self._simple_command(name)
          File "/usr/local/lib/python2.7/imaplib.py", line 1088, in 
_simple_command
                return self._command_complete(name, self._command(name, *args))
          File "/usr/local/lib/python2.7/imaplib.py", line 910, in 
_command_complete
                typ, data = self._get_tagged_response(tag)
          File "/usr/local/lib/python2.7/imaplib.py", line 1017, in 
_get_tagged_response
                self._get_response()
          File "/usr/local/lib/python2.7/imaplib.py", line 929, in _get_response
                resp = self._get_line()
          File "/usr/local/lib/python2.7/imaplib.py", line 1027, in _get_line
                line = self.readline()
          File "/usr/local/lib/python2.7/imaplib.py", line 1189, in readline
                return self.file.readline()
          File "/usr/local/lib/python2.7/socket.py", line 451, in readline
                data = self._sock.recv(self._rbufsize)
          File "/usr/local/lib/python2.7/ssl.py", line 734, in recv
                return self.read(buflen)
          File "/usr/local/lib/python2.7/ssl.py", line 621, in read
                v = self._sslobj.read(len or 1024)
        KeyboardInterrupt

The same way I tested that it hangs with Python 3.4.4.

I think it is a bug because it hangs instead of raising an exception with 
helpful information.
Maybe it is caused by removing RC4 cipher from new versions of Python?

How can I workaround this problem?

----------
messages: 260398
nosy: mniklas
priority: normal
severity: normal
status: open
title: New versions of Python hangs on imaplib.IMAP4_SSL()
type: behavior
versions: Python 2.7, Python 3.4

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26375>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to