Use SMTPUTF8 policy, add more debug logging

This commit is contained in:
Piotr F. Mieszkowski 2022-11-30 22:44:48 +01:00
parent 4da4019321
commit b94123e83e
3 changed files with 9 additions and 4 deletions

View File

@ -28,7 +28,7 @@ import copy
import email
import email.message
import email.utils
from email.policy import SMTP
from email.policy import SMTPUTF8
import GnuPG
import os
import smtplib
@ -124,7 +124,7 @@ def _gpg_encrypt_copy(message, cmdline, to, encrypt_f):
def _gpg_encrypt_to_bytes(message, cmdline, to, encrypt_f) -> bytes:
msg_copy = _gpg_encrypt_copy(message, cmdline, to, encrypt_f)
return msg_copy.as_bytes(policy=SMTP)
return msg_copy.as_bytes(policy=SMTPUTF8)
def _gpg_encrypt_to_str(message, cmdline, to, encrypt_f) -> str:

View File

@ -102,9 +102,14 @@ class KeyRing:
async def _load(self):
last_mod = self._read_mod_time()
LOG.debug(f'Keyring was last modified: {last_mod}')
if self._is_modified(last_mod):
LOG.debug('Keyring has been modified')
async with self._sema:
LOG.debug('About to re-load the keyring')
self.replace_keyring(self._load_keyring_from(self._path))
else:
LOG.debug('Keyring not modified recently, continuing')
self._last_mod = self._read_mod_time()

View File

@ -16,7 +16,7 @@ There are 3 operations available:
import logging
import lacre.core as core
from email.message import Message
from email.policy import SMTP
from email.policy import SMTP, SMTPUTF8
LOG = logging.getLogger(__name__)
@ -124,7 +124,7 @@ class KeepIntact(MailOperation):
def perform(self, message: Message) -> bytes:
"""Return MESSAGE unmodified."""
return message.as_bytes(policy=SMTP)
return message.as_bytes(policy=SMTPUTF8)
def __repr__(self):
"""Return representation with just method and email."""