python / cpython

The Python programming language
https://www.python.org
Other
63.39k stars 30.35k forks source link

IMAP4_SSL() class incompatible with socket.timeout #40435

Closed f4a1bbfb-a847-4cb4-9cad-086fc78fc74d closed 20 years ago

f4a1bbfb-a847-4cb4-9cad-086fc78fc74d commented 20 years ago
BPO 977680
Nosy @brettcannon

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 = ['library'] title = 'IMAP4_SSL() class incompatible with socket.timeout' updated_at = user = 'https://bugs.python.org/melicertes' ``` bugs.python.org fields: ```python activity = actor = 'brett.cannon' assignee = 'none' closed = True closed_date = None closer = None components = ['Library (Lib)'] creation = creator = 'melicertes' dependencies = [] files = [] hgrepos = [] issue_num = 977680 keywords = [] message_count = 2.0 messages = ['21245', '21246'] nosy_count = 2.0 nosy_names = ['brett.cannon', 'melicertes'] pr_nums = [] priority = 'normal' resolution = 'fixed' stage = None status = 'closed' superseder = None type = None url = 'https://bugs.python.org/issue977680' versions = ['Python 2.3'] ```

f4a1bbfb-a847-4cb4-9cad-086fc78fc74d commented 20 years ago

If you do socket.setdefaulttimeout(X) before trying to instantiate imaplib.IMAP4_SSL(), the connection hangs partway through the SSL negotiation.

The cause is that socket.ssl() is actually incompatible with timeouts (not sure why) and IMAP4_SSL() doesn't do anything to guard against it. It should do .setblocking(1) on the socket.socket object before passing it to socket.ssl().

The documentation should also clarify timeouts not working with socket.ssl.

brettcannon commented 20 years ago

Logged In: YES user_id=357491

Patch bpo-945642 seems to fix this. Closing as fixed.