Skip to content

Commit 823eba6

Browse files
committed
Fix body_line_iterator(decode=True) returning no lines in Python 3.11
Python 3.11's body_line_iterator only yields str payloads. When decode=True, get_payload() returns bytes, which the iterator silently drops — leaving SimpleMatch, SimpleWarning, and Tagger with nothing to scan. Remove decode=True (defaulting to False) so get_payload() returns str as expected. Bounce detection and topic tagging now work correctly under Python 3.
1 parent 51e0499 commit 823eba6

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

Mailman/Bouncers/SimpleMatch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def process(msg, patterns=None):
224224
# we process the message multiple times anyway.
225225
for scre, ecre, acre in patterns:
226226
state = 0
227-
for line in email.iterators.body_line_iterator(msg, decode=True):
227+
for line in email.iterators.body_line_iterator(msg):
228228
if state == 0:
229229
if scre.search(line):
230230
state = 1

Mailman/Bouncers/SimpleWarning.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def process(msg):
7575
addrs = {}
7676
for scre, ecre, acre in patterns:
7777
state = 0
78-
for line in email.iterators.body_line_iterator(msg, decode=True):
78+
for line in email.iterators.body_line_iterator(msg):
7979
if state == 0:
8080
if scre.search(line):
8181
state = 1

Mailman/Handlers/Tagger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def scanbody(msg, numlines=None):
9797
# the first numlines of body text.
9898
lines = []
9999
lineno = 0
100-
reader = list(email.iterators.body_line_iterator(msg, decode=True))
100+
reader = list(email.iterators.body_line_iterator(msg))
101101
while numlines is None or lineno < numlines:
102102
try:
103103
line = reader.pop(0)

0 commit comments

Comments
 (0)