Skip to content

Commit ba97bdf

Browse files
committed
bpo-32680 add default "sock" on SMTP objects
By default the smtplib.SMTP objects did not have a sock attribute, it was only created during connect()
1 parent e76daeb commit ba97bdf

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

Lib/smtplib.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ class SMTP:
216216
method called 'sendmail' that will do an entire mail transaction.
217217
"""
218218
debuglevel = 0
219+
220+
sock = None
219221
file = None
220222
helo_resp = None
221223
ehlo_msg = "ehlo"
@@ -344,7 +346,7 @@ def send(self, s):
344346
"""Send `s' to the server."""
345347
if self.debuglevel > 0:
346348
self._print_debug('send:', repr(s))
347-
if hasattr(self, 'sock') and self.sock:
349+
if self.sock:
348350
if isinstance(s, str):
349351
# send is used by the 'data' command, where command_encoding
350352
# should not be used, but 'data' needs to convert the string to

0 commit comments

Comments
 (0)