#1144262 getmail6: TypeError ... encoding with 'imap4-utf-7' codec failed

#1144262#5
Date:
2026-08-13 07:28:26 UTC
From:
To:
As of a few days ago, maybe with the change to from python 3.14.6 to
3.14.7, getmail6 started throwing the following error after fetching the
emails via imapssl:

  getmail version 6.19.12
  Python version 3.14.7 (main, Aug 11 2026, 08:48:35) [GCC 16.2.0]

Unhandled exception follows:
    File "/usr/bin/getmail", line 1091, in main
    success = go(configs, options.idle, options.only_account)
    File "/usr/bin/getmail", line 197, in go
    retriever.select_mailbox(mailbox)
    ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
    File "/usr/lib/python3/dist-packages/getmailcore/_retrieverbases.py", line 1621, in select_mailbox
    codecs.encode(
    ~~~~~~~~~~~~~^
        self.conn._quote(mailbox),
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
        'imap4-utf-7'),
        ^^^^^^^^^^^^^^
    File "/usr/lib/python3/dist-packages/getmailcore/imap_utf7.py", line 96, in encoder
    r.extend(b'&' + modified_base64(''.join(_in)) + b'-')
                                    ~~~~~~~^^^^^
  TypeError: sequence item 0: expected str instance, int found
  encoding with 'imap4-utf-7' codec failed

Here are the configuration options (from --dump):

getmail version 6.19.12
Copyright (C) 1998-2026 Charles Cazabon and others. Licensed under GPL-2.0.
getmail configuration:
  getmail version 6.19.12
  Python version 3.14.7 (main, Aug 11 2026, 08:48:35) [GCC 16.2.0]
  retriever:  SimpleIMAPSSLRetriever(ca_certs="None", certfile="CERTFILE.crt.pem", getmaildir="DIR/.getmail", imap_id_extension="False", imap_on_delete="None", imap_search="None", keyfile="KEYFILE.key.pem", mailboxes="('Inbox', 'Sent Items', 'Junk Email')", move_on_delete="fetched_by_laptop", password="*", password_command="('getmail-gmail-xoauth-tokens', 'DIR/provider.json')", port="993", record_mailbox="True", server="outlook.office365.com", ssl_cert_hostname="None", ssl_ciphers="None", ssl_fingerprints="()", ssl_version="None", timeout="180", uid_cache="None", use_cram_md5="False", use_kerberos="False", use_peek="True", use_xoauth2="True", username="EMAIL@DOMAIN")
  destination:  MDA_external(allow_root_commands="False", arguments="()", command="procmail", group="None", ignore_stderr="False", path="/usr/bin/procmail", pipe_stdout="True", unixfrom="True", user="None")
  options:
    delete : True
    delete_after : 0
    delete_bigger_than : 0
    delivered_to : False
    fingerprint : False
    logfile : logfile(filename="~/.getmail/log")
    mark_read : False
    max_bytes_per_session : 0
    max_message_size : 0
    max_messages_per_session : 0
    message_log : ~/.getmail/log
    message_log_syslog : False
    message_log_verbose : False
    netrc_file : None
    only_oldmail_file : False
    read_all : True
    received : True
    skip_imap_fetch_size : False
    to_oldmail_on_each_mail : False
    use_netrc : False
    verbose : 2