Exception in Microsoft detector
The script that triggered this error has been running successfully on a test mbox of about 45 messages. This morning when confronted with a much larger input set (23,000 messages), it threw the following exceptions. There's a try block around the per-message stuff, so it would appear two different messages caused these.
Exception in detector: <class 'flufl.bounce._detectors.microsoft.Microsoft'>
Traceback (most recent call last):
File "/opt/local/lib/python3.7/site-packages/flufl/bounce/_scan.py", line 43,
in scan_message
temporary, permanent = detector_class().process(msg)
File
"/opt/local/lib/python3.7/site-packages/flufl/bounce/_detectors/microsoft.py",
line 47, in process
if '@' in line:
TypeError: a bytes-like object is required, not 'str'
Traceback (most recent call last):
File "/root/commonsbounce_desubber", line 52, in <module>
bounces = flufl.bounce.scan_message(msgo)
File "/opt/local/lib/python3.7/site-packages/flufl/bounce/_scan.py", line 43,
in scan_message
temporary, permanent = detector_class().process(msg)
File
"/opt/local/lib/python3.7/site-packages/flufl/bounce/_detectors/microsoft.py",
line 47, in process
if '@' in line:
TypeError: a bytes-like object is required, not 'str'
The basic code, stripped of its comments and try/except blocks, looks something like this:
dabox = mailbox.mbox('/path/to/mboxfile', None, False)
for key in dabox.iterkeys():
msgstr = dabox.get_string(key)
msgo = email.parser.Parser().parsestr(msgstr)
bounces = flufl.bounce.scan_message(msgo)