# -*- coding: utf-8 -*- import mailbox import os # Create an example folder, the path is an unicode string prefix = u'répertoire/' if not os.path.exists(prefix): os.mkdir(prefix) # Open a maildir box maildir_path = os.path.join(prefix, "mail/") mb = mailbox.Maildir(maildir_path, factory=None) # Create a dummy message msg = mailbox.MaildirMessage() msg.set_payload('This is a test') msg.set_flags('S') key = mb.add(msg) # Try to get the message back mb.get_message(key) # This triggers a TypeError in mailbox.py:343 in get_message