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.

classification
Title: Python 2.7.10 and 3.4.4 hang on imaplib.IMAP4_SSL()
Type: behavior Stage: resolved
Components: Versions: Python 3.6, Python 3.5, Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: iritkatriel, larry, maciej.szulik, mcepl, mniklas, terry.reedy
Priority: normal Keywords:

Created on 2016-02-17 13:39 by mniklas, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (7)
msg260398 - (view) Author: Michal Niklas (mniklas) Date: 2016-02-17 13:39
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?
msg260543 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-02-20 00:35
where was the 'RC4 cipher' removed from.  Do you know the issue or commit that did so?
msg260631 - (view) Author: Michal Niklas (mniklas) Date: 2016-02-21 19:02
Of course I'm not sure if it is related with RC4 removal, but I have found it in changelog for Python 2.7.10: https://hg.python.org/cpython/raw-file/15c95b7d81dc/Misc/NEWS
Issue #23481: Remove RC4 from the SSL module's default cipher list.
msg315558 - (view) Author: Matej Cepl (mcepl) * Date: 2018-04-21 09:10
Are you able to reproduce it with IMAP4.debug value set to 3 or more? Clean up passwords etc. and paste the log here, please. Thank you.
msg341887 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2019-05-08 15:23
3.4 is now EOL, so the 3.4regression tag goes away too.
msg400952 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-09-02 20:34
Michal, is still issue still relevant?

The url you mention no longer exists so I can't see if it's still reproducible:


% nslookup imap.home.pl
Server:		192.168.1.254
Address:	192.168.1.254#53

** server can't find imap.home.pl: NXDOMAIN
msg402175 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-09-19 22:22
Please create a new issue, with a working reproducer, if this problem exists in a current version.
History
Date User Action Args
2022-04-11 14:58:27adminsetgithub: 70563
2021-09-19 22:22:32iritkatrielsetstatus: pending -> closed
resolution: out of date
messages: + msg402175

stage: test needed -> resolved
2021-09-02 20:34:00iritkatrielsetstatus: open -> pending
nosy: + iritkatriel
messages: + msg400952

2019-05-08 15:23:32larrysetversions: - Python 3.4
nosy: + larry

messages: + msg341887

keywords: - 3.4regression
2018-04-21 09:10:30mceplsetnosy: + mcepl
messages: + msg315558
2016-02-23 10:15:19maciej.szuliksetnosy: + maciej.szulik
2016-02-21 19:02:35mniklassetmessages: + msg260631
2016-02-20 00:35:02terry.reedysettitle: New versions of Python hangs on imaplib.IMAP4_SSL() -> Python 2.7.10 and 3.4.4 hang on imaplib.IMAP4_SSL()

keywords: + 3.4regression
nosy: + terry.reedy
versions: + Python 3.5, Python 3.6
messages: + msg260543
stage: test needed
2016-02-17 13:39:17mniklascreate