summaryrefslogtreecommitdiffstats
path: root/Lib/smtplib.py
diff options
context:
space:
mode:
authorRomuald Brunet <romuald@chivil.com>2018-10-09 14:31:55 (GMT)
committerGiampaolo Rodola <g.rodola@gmail.com>2018-10-09 14:31:55 (GMT)
commit7b313971805ca9b53f181f7b97e5376d0b89dc06 (patch)
treeb20b1345e8991acc211fcafa2e7f8fd9f9317eb1 /Lib/smtplib.py
parent2b2758d0b30f4ed7d37319d6c18552eccbc8e7b7 (diff)
downloadcpython-7b313971805ca9b53f181f7b97e5376d0b89dc06.zip
cpython-7b313971805ca9b53f181f7b97e5376d0b89dc06.tar.gz
cpython-7b313971805ca9b53f181f7b97e5376d0b89dc06.tar.bz2
bpo-32680 add default "sock" on SMTP objects (#5345)
By default the smtplib.SMTP objects did not have a sock attribute, it was only created during connect()
Diffstat (limited to 'Lib/smtplib.py')
-rwxr-xr-xLib/smtplib.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/smtplib.py b/Lib/smtplib.py
index 5e1bc0b..acfc358 100755
--- a/Lib/smtplib.py
+++ b/Lib/smtplib.py
@@ -216,6 +216,8 @@ class SMTP:
method called 'sendmail' that will do an entire mail transaction.
"""
debuglevel = 0
+
+ sock = None
file = None
helo_resp = None
ehlo_msg = "ehlo"
@@ -344,7 +346,7 @@ class SMTP:
"""Send `s' to the server."""
if self.debuglevel > 0:
self._print_debug('send:', repr(s))
- if hasattr(self, 'sock') and self.sock:
+ if self.sock:
if isinstance(s, str):
# send is used by the 'data' command, where command_encoding
# should not be used, but 'data' needs to convert the string to