Well, I noticed a second problem with my code.

On 2025-05-30 01:00, Stephen J. Turnbull wrote:
Thomas Ward via Mailman-Developers writes:

  > (1) What is the datatype of `msg` in the archive_message class?

Ask not what is the data type of `msg`.  Ask instead what is the data
type of `msg['Subject']`.  I expect that it's `email.header.Header`.
Try `TID_PATTERN.search(str(message_subject))[0]`.

... and knowing the type that `msg` is out of the box is important to that. In later Python, there is a class of message called `email.message.EmailMessage` which has a few extra things than just `email.message.Message` (I think this is yielded by `email.parser` objects). By knowing that the class is essentially a subclass with some fixes of `email.message.Message` then the `iter_attachments()` approach I was using to iterate over attachments in the email message won't work because that is only part of `email.message.EmailMessage`.

Which is where knowing the core datatype of `msg` passed into the archiver function by Mailman helps. Because now I have to do the Old School(TM) way of iterating over `msg.walk()` and then determining if the message part has a content disposition and then confirm if it's an attachment or not and then have fun with it.

This said, `msg.get('Subject', '')` also seemed to fail (but I usually use that instead of referring to `msg['HEADER']` directly where possible)

I'll be testing this today, but knowing what the core datatype of `msg` is will actually help with knowing which functions I need to call against the `msg`. ;)

Thomas
_______________________________________________
Mailman-Developers mailing list -- mailman-developers@python.org
To unsubscribe send an email to mailman-developers-le...@python.org
https://mail.python.org/mailman3/lists/mailman-developers.python.org/
Mailman FAQ: https://wiki.list.org/x/AgA3

Security Policy: https://wiki.list.org/x/QIA9

Reply via email to