bpo-34246: Use no mutable default args in smtplib (GH-8554) · python/cpython@9835696 (original) (raw)

`@@ -513,7 +513,7 @@ def noop(self):

`

513

513

`"""SMTP 'noop' command -- doesn't do anything :>"""

`

514

514

`return self.docmd("noop")

`

515

515

``

516

``

`-

def mail(self, sender, options=[]):

`

``

516

`+

def mail(self, sender, options=()):

`

517

517

`"""SMTP 'mail' command -- begins mail xfer session.

`

518

518

``

519

519

` This method may raise the following exceptions:

`

`@@ -534,7 +534,7 @@ def mail(self, sender, options=[]):

`

534

534

`self.putcmd("mail", "FROM:%s%s" % (quoteaddr(sender), optionlist))

`

535

535

`return self.getreply()

`

536

536

``

537

``

`-

def rcpt(self, recip, options=[]):

`

``

537

`+

def rcpt(self, recip, options=()):

`

538

538

`"""SMTP 'rcpt' command -- indicates 1 recipient for this mail."""

`

539

539

`optionlist = ''

`

540

540

`if options and self.does_esmtp:

`

`@@ -785,8 +785,8 @@ def starttls(self, keyfile=None, certfile=None, context=None):

`

785

785

`raise SMTPResponseException(resp, reply)

`

786

786

`return (resp, reply)

`

787

787

``

788

``

`-

def sendmail(self, from_addr, to_addrs, msg, mail_options=[],

`

789

``

`-

rcpt_options=[]):

`

``

788

`+

def sendmail(self, from_addr, to_addrs, msg, mail_options=(),

`

``

789

`+

rcpt_options=()):

`

790

790

`"""This command performs an entire mail transaction.

`

791

791

``

792

792

` The arguments are:

`

`@@ -890,7 +890,7 @@ def sendmail(self, from_addr, to_addrs, msg, mail_options=[],

`

890

890

`return senderrs

`

891

891

``

892

892

`def send_message(self, msg, from_addr=None, to_addrs=None,

`

893

``

`-

mail_options=[], rcpt_options={}):

`

``

893

`+

mail_options=(), rcpt_options=()):

`

894

894

`"""Converts message to a bytestring and passes it to sendmail.

`

895

895

``

896

896

` The arguments are as for sendmail, except that msg is an

`

`@@ -958,7 +958,7 @@ def send_message(self, msg, from_addr=None, to_addrs=None,

`

958

958

`if international:

`

959

959

`g = email.generator.BytesGenerator(

`

960

960

`bytesmsg, policy=msg.policy.clone(utf8=True))

`

961

``

`-

mail_options += ['SMTPUTF8', 'BODY=8BITMIME']

`

``

961

`+

mail_options = (*mail_options, 'SMTPUTF8', 'BODY=8BITMIME')

`

962

962

`else:

`

963

963

`g = email.generator.BytesGenerator(bytesmsg)

`

964

964

`g.flatten(msg_copy, linesep='\r\n')

`