[New-bugs-announce] [issue20903] smtplib.SMTP raises socket.timeout

Chris Clark report at bugs.python.org
Wed Mar 12 23:52:34 CET 2014


New submission from Chris Clark:

The documentation for smtplib.SMTP says "If the connect() call returns anything other than a success code, an SMTPConnectError is raised." It doesn't explicitly specify what happens when connect() raises instead of returns, but I think either the documentation should mention "socket.timeout" or it should raise SMTPConnectError.


Python 3.3.4 (default, Feb 11 2014, 15:56:08) 
[GCC 4.8.2 20140206 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from smtplib import SMTP
>>> SMTP('a.com', timeout=1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.3/smtplib.py", line 241, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/lib/python3.3/smtplib.py", line 320, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/usr/lib/python3.3/smtplib.py", line 291, in _get_socket
    self.source_address)
  File "/usr/lib/python3.3/socket.py", line 435, in create_connection
    raise err
  File "/usr/lib/python3.3/socket.py", line 426, in create_connection
    sock.connect(sa)
socket.timeout: timed out

----------
components: Library (Lib)
messages: 213321
nosy: Chris.Clark
priority: normal
severity: normal
status: open
title: smtplib.SMTP raises socket.timeout
type: behavior
versions: Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20903>
_______________________________________


More information about the New-bugs-announce mailing list