[issue20903] smtplib.SMTP raises socket.timeout
Milan Oberkirch added the comment: Should this task get closed? (see comment above) -- nosy: +jesstess ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20903 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20903] smtplib.SMTP raises socket.timeout
Roundup Robot added the comment: New changeset 6cd64ef6fc95 by R David Murray in branch '2.7': #20903: clarify what happens when an smtp connection timeout occurs. http://hg.python.org/cpython/rev/6cd64ef6fc95 New changeset ca88bcfa5c15 by R David Murray in branch '3.4': #20903: clarify what happens when an smtp connection timeout occurs. http://hg.python.org/cpython/rev/ca88bcfa5c15 New changeset 20225460ae0f by R David Murray in branch 'default': Merge: #20903: clarify what happens when an smtp connection timeout occurs. http://hg.python.org/cpython/rev/20225460ae0f -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20903 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20903] smtplib.SMTP raises socket.timeout
R. David Murray added the comment: Well, now that I applied your patch it can be :) Thanks. -- resolution: - fixed stage: needs patch - resolved status: open - closed versions: -Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20903 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20903] smtplib.SMTP raises socket.timeout
Vyacheslav Rafalskiy added the comment: Take look at this one too: http://bugs.python.org/issue2118 It is supposed to be fixed. -- nosy: +Vyacheslav.Rafalskiy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20903 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20903] smtplib.SMTP raises socket.timeout
Milan Oberkirch added the comment: The attached patch mentions the exception besides the description of the timeout parameter. It doesn't hurt and makes programmers aware of this common exception. -- keywords: +patch nosy: +zvyn Added file: http://bugs.python.org/file34516/doc_socket_timeout.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20903 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20903] smtplib.SMTP raises socket.timeout
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 rep...@bugs.python.org http://bugs.python.org/issue20903 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20903] smtplib.SMTP raises socket.timeout
R. David Murray added the comment: In general we don't document what gets raised unless it is unique to a module or has non-obvious implications. In this case, getting socket exceptions out of a network library should be obvious in some sense :). In particular, both SMTPConnectError and socket.error are subclasses of OSError, so if you want to catch them all, catch OSError. Now, that said, I have some sympathy to the idea that something triggered by a parameter to the call should perhaps result in an SMTPConnectError. However, the argument *against* it is that it makes it difficult to differentiate the timeout error from other connection errors, which one might well want to do. We've moved toward making it easier to tell classes of errors apart (see PEP 3151), so this would be a regression in that approach. Given that the timeout is part of the signature, I think it does make sense to mention that the timeout will raise a socket.timeout error. -- assignee: - docs@python components: +Documentation -Library (Lib) keywords: +easy nosy: +docs@python, r.david.murray stage: - needs patch versions: +Python 3.4, Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20903 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20903] smtplib.SMTP raises socket.timeout
Chris Clark added the comment: I am concerned about the policy of not documenting all exceptions that are raised. It sounds like there is no straightforward way to write a comprehensive except statement without using a bare except or catching some base exception. I consider it dangerous to catch broad exception classes because it can hide some nasty bugs. And while I may be able to use OSError here, how can I be sure that you aren't forgetting about some other unexpected exception? Furthermore, I don't want to catch all OSErrors, only those relating to the SMTP server connection failing. I definitely agree that it is preferable to be able to differentiate different types of exceptions. It seems to me that the best solution would be to make subclasses of SMTPConnectError so that I can catch SMTPConnectError if I don't care about the type or SMTPConnectTimeoutError if I do care about the type. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20903 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com