mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
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()
This commit is contained in:
parent
2b2758d0b3
commit
7b31397180
3 changed files with 11 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue