diff --git a/unattended-upgrade b/unattended-upgrade index 86358b19..d5797d60 100755 --- a/unattended-upgrade +++ b/unattended-upgrade @@ -27,7 +27,6 @@ import contextlib import copy import datetime import errno -import email.charset import fcntl import fnmatch import gettext @@ -40,6 +39,7 @@ import grp import inspect import io from importlib.abc import Loader +import importlib import importlib.util import locale import logging @@ -71,7 +71,6 @@ except ImportError: from collections import defaultdict, namedtuple from datetime import date -from email.message import Message from gettext import gettext as _ from io import StringIO from optparse import ( @@ -1613,6 +1612,10 @@ def _send_mail_using_mailx(from_address, to_address, subject, body): def _send_mail_using_sendmail(from_address, to_address, subject, body): + # workaround LP:2080940, email.errors changes as part of a security + # update in python itself so import this as late as possible + import email.charset + from email.message import Message # type: (str, str, str, str) -> int # format as a proper mail msg = Message()