

def encode(self, encoding=None):
    name_string = None
    if (encoding is None):
        encoding = self.encoding
    if (encoding != 'ascii'):
        try:
            self.name.encode('ascii', errors='strict')
        except UnicodeError:
            pass
        else:
            name_string = self.name
    if (name_string is None):
        name_string = Header(self.name, encoding).encode()
    (localpart, domain) = self.address.split('@', 1)
    domain = domain.encode('idna').decode()
    address = '@'.join((address, domain))
    return formataddr((name_string, address)).replace('\n', '').encode(encoding)

dataset/ETHPy150Open marrow/mailer/marrow/mailer/address.py Address.encode/VarMisuse@143/169 `localpart`->`address`