[issue2118] smtplib.SMTP() raises socket.error rather than SMTPConnectError

R. David Murray report at bugs.python.org
Mon Sep 13 03:19:36 CEST 2010


R. David Murray <rdmurray at bitdance.com> added the comment:

I discussed this issue with Antoine Pitrou on #python-dev, and his opinion is that SMTPSocketConnectError doesn't add enough value to be worthwhile.  So he is in favor of making this a doc fix.

However, the suggestion also came up to have SMTPException subclass from IOError instead of Exception, since every place where an SMTPException is raised IO is involved.  This change would mean that code that didn't care what kind of IO error causes the connection to fail could trap just IOError, and code that did care could trap SMTPConnectError and IOError separately.

It is possible this would have backward compatibility issues, so the base class change is probably suitable only for 3.2, but a doc change clarifying that non-SMTP errors can be raised by connect should be backported.

----------
nosy: +giampaolo.rodola, pitrou
resolution: accepted -> 
stage: patch review -> needs patch

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


More information about the Python-bugs-list mailing list